opencode-swarm 7.132.2 → 7.134.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 (122) hide show
  1. package/README.md +4 -1
  2. package/dist/agents/agent-output-schema.d.ts +74 -0
  3. package/dist/agents/critic.d.ts +2 -1
  4. package/dist/agents/reviewer.d.ts +1 -1
  5. package/dist/background/completion-observer.d.ts +17 -5
  6. package/dist/background/pending-delegations.d.ts +315 -2
  7. package/dist/background/stage-b-gates.d.ts +2 -0
  8. package/dist/cli/{config-doctor-bp5spb79.js → config-doctor-t5r92674.js} +3 -3
  9. package/dist/cli/{core-wg3re04e.js → core-d6yd2jzv.js} +2 -2
  10. package/dist/cli/{curation-policy-7zp2m9gv.js → curation-policy-3smfn2a3.js} +7 -7
  11. package/dist/cli/{curator-drift-y1wm4atk.js → curator-drift-tsyyf4b4.js} +4 -4
  12. package/dist/cli/{curator-h067mrcc.js → curator-hva8f3nf.js} +31 -29
  13. package/dist/cli/{curator-llm-factory-605d08hf.js → curator-llm-factory-p3aqev12.js} +31 -29
  14. package/dist/cli/{dispatch-3mhgqj2x.js → dispatch-gxbeb2ps.js} +2 -2
  15. package/dist/cli/{evidence-summary-service-jfagmvrh.js → evidence-summary-service-mrzsjpg4.js} +12 -11
  16. package/dist/cli/{gate-evidence-cy2te3x8.js → gate-evidence-b5v1xvxp.js} +4 -4
  17. package/dist/cli/guardrail-explain-k8mcvk61.js +57 -0
  18. package/dist/cli/{guardrail-log-aa112fxv.js → guardrail-log-absma1rv.js} +5 -5
  19. package/dist/cli/{hive-promoter-nv0m5rzk.js → hive-promoter-jwd51gzk.js} +31 -29
  20. package/dist/cli/{index-g4mnf3p5.js → index-1j3682j8.js} +5 -5
  21. package/dist/cli/{index-6ccynjv3.js → index-2njes601.js} +8 -8
  22. package/dist/cli/{index-w9cb5zwh.js → index-2t1n9k7b.js} +4 -4
  23. package/dist/cli/{index-f6480ee6.js → index-3dtjhr26.js} +5259 -1759
  24. package/dist/cli/{index-2tn5h2zp.js → index-4p02dp92.js} +6 -6
  25. package/dist/cli/index-b4z7s917.js +80 -0
  26. package/dist/cli/{index-bvp2v7k1.js → index-b5ek2cge.js} +266 -19
  27. package/dist/cli/index-b8zgtz81.js +123 -0
  28. package/dist/cli/{index-3s9rfnqq.js → index-baawkm48.js} +12 -12
  29. package/dist/cli/{index-fgcmxjp7.js → index-c3e0ymrg.js} +1 -1
  30. package/dist/cli/{index-q27bajqb.js → index-cfkvc5q9.js} +3 -3
  31. package/dist/cli/{index-7mkpsw6g.js → index-dd7ttx8x.js} +1 -1
  32. package/dist/cli/{index-jgfcp9bh.js → index-dgxgvzab.js} +7 -7
  33. package/dist/cli/{index-8d3m0ge3.js → index-eedq2y40.js} +48 -34
  34. package/dist/cli/{index-630badhp.js → index-g87ty4wp.js} +149 -6
  35. package/dist/cli/{index-yvv1wt2h.js → index-hgh01f6h.js} +25 -3
  36. package/dist/cli/{index-9cf1yr67.js → index-j6ywarjp.js} +3 -3
  37. package/dist/cli/{index-mwkwyej1.js → index-jpkxjmfw.js} +5 -5
  38. package/dist/cli/{index-03zyn94g.js → index-k742ecbm.js} +178 -222
  39. package/dist/cli/{index-y5qp59rc.js → index-kapharv7.js} +10 -4
  40. package/dist/cli/{index-djwemsjn.js → index-m2s0gbzt.js} +2 -2
  41. package/dist/cli/{index-4ff0x4cg.js → index-p8hezdtz.js} +1 -1
  42. package/dist/cli/{index-k4tmx21m.js → index-rkyhv4p5.js} +2 -2
  43. package/dist/cli/{index-3x761jqv.js → index-wk1h5ec2.js} +1 -1
  44. package/dist/cli/{index-jj4earrh.js → index-xfejq1p9.js} +1 -1
  45. package/dist/cli/{index-rt5jgktq.js → index-y0kk3rtv.js} +2 -2
  46. package/dist/cli/index-y3v1404y.js +1625 -0
  47. package/dist/cli/index.js +35 -31
  48. package/dist/cli/{knowledge-escalator-j0nceas7.js → knowledge-escalator-mkdac2m7.js} +8 -8
  49. package/dist/cli/{knowledge-events-gpqc62jr.js → knowledge-events-jjc9qbe0.js} +6 -6
  50. package/dist/cli/{knowledge-link-4yd2z8ev.js → knowledge-link-nc4y2zkq.js} +5 -5
  51. package/dist/cli/{knowledge-store-ggxr3ww5.js → knowledge-store-9e0w1kxm.js} +6 -6
  52. package/dist/cli/{knowledge-validator-007smap6.js → knowledge-validator-h1nrn2pk.js} +9 -9
  53. package/dist/cli/pending-delegations-v9e40hfk.js +96 -0
  54. package/dist/cli/{pr-subscriptions-zqbmctwz.js → pr-subscriptions-ztq40hrt.js} +7 -7
  55. package/dist/cli/{scan-cursor-wz4bff7a.js → scan-cursor-mk3tq3sf.js} +7 -7
  56. package/dist/cli/{schema-023gwne7.js → schema-bjb0yzsq.js} +7 -3
  57. package/dist/cli/{scope-persistence-dm5bab50.js → scope-persistence-hz3zmmsv.js} +5 -5
  58. package/dist/cli/{skill-generator-rtsg1m7x.js → skill-generator-p1de0wkr.js} +10 -10
  59. package/dist/cli/worktree-collision-ownership-c4bdnjtx.js +221 -0
  60. package/dist/commands/command-dispatch.d.ts +7 -0
  61. package/dist/commands/index.d.ts +7 -0
  62. package/dist/commands/registry.d.ts +16 -0
  63. package/dist/commands/review.d.ts +21 -0
  64. package/dist/config/agent-names.d.ts +3 -3
  65. package/dist/config/evidence-schema.d.ts +47 -47
  66. package/dist/config/index.d.ts +2 -2
  67. package/dist/config/schema.d.ts +58 -6
  68. package/dist/consensus/contracts.d.ts +3 -3
  69. package/dist/evaluation/ephemeral-agent-dispatcher.d.ts +64 -0
  70. package/dist/evaluation/model-dispatcher.d.ts +11 -5
  71. package/dist/hooks/auto-review.d.ts +30 -65
  72. package/dist/hooks/delegation-gate/worktree-collision-ownership.d.ts +28 -0
  73. package/dist/hooks/delegation-gate/worktree-isolation.d.ts +63 -1
  74. package/dist/hooks/delegation-gate/worktree-merge-status.d.ts +14 -0
  75. package/dist/hooks/delegation-gate/worktree-ownership-tag.d.ts +19 -0
  76. package/dist/hooks/delegation-gate/worktree-provisioning-owner.d.ts +30 -0
  77. package/dist/hooks/delegation-gate.d.ts +15 -6
  78. package/dist/hooks/guardrails/tool-before.d.ts +8 -0
  79. package/dist/hooks/index.d.ts +1 -1
  80. package/dist/hooks/init-orphan-recovery.d.ts +17 -0
  81. package/dist/hooks/review-receipt-collector.d.ts +53 -10
  82. package/dist/hooks/review-receipt-scope.d.ts +74 -0
  83. package/dist/hooks/review-receipt.d.ts +104 -10
  84. package/dist/hooks/reviewer-scope-file-fingerprint.d.ts +21 -0
  85. package/dist/hooks/reviewer-scope-lifecycle.d.ts +19 -0
  86. package/dist/hooks/task-result-classifier.d.ts +6 -0
  87. package/dist/index.d.ts +2 -0
  88. package/dist/index.js +583 -524
  89. package/dist/memory/schema.d.ts +1 -1
  90. package/dist/review/contracts.d.ts +29 -0
  91. package/dist/review/diff-source.d.ts +134 -0
  92. package/dist/review/engine.d.ts +60 -0
  93. package/dist/review/evidence.d.ts +88 -0
  94. package/dist/review/finding-validator.d.ts +77 -0
  95. package/dist/review/phase-runner.d.ts +37 -0
  96. package/dist/review/runtime.d.ts +32 -0
  97. package/dist/scope/scope-binding.d.ts +9 -0
  98. package/dist/services/config-doctor.d.ts +12 -0
  99. package/dist/session/snapshot-writer.d.ts +2 -0
  100. package/dist/state.d.ts +222 -1
  101. package/dist/tools/dispatch-lanes.d.ts +3 -1
  102. package/dist/tools/epic-record-divergence.d.ts +5 -5
  103. package/dist/tools/lean-turbo-review.d.ts +4 -1
  104. package/dist/tools/lean-turbo-run-phase.d.ts +3 -1
  105. package/dist/tools/phase-complete/gates/final-review-gate.d.ts +18 -0
  106. package/dist/tools/phase-complete/gates/index.d.ts +1 -0
  107. package/dist/tools/phase-complete/gates/types.d.ts +10 -0
  108. package/dist/tools/phase-complete.d.ts +13 -1
  109. package/dist/tools/plugin-registration.d.ts +3 -1
  110. package/dist/tools/swarm-command.d.ts +4 -1
  111. package/dist/tools/tool-metadata.d.ts +22 -22
  112. package/dist/turbo/lean/integration.d.ts +18 -2
  113. package/dist/turbo/lean/reviewer.d.ts +19 -3
  114. package/dist/turbo/lean/runner.d.ts +1 -1
  115. package/dist/worktree/merge.d.ts +47 -1
  116. package/package.json +1 -1
  117. package/dist/cli/guardrail-explain-s7vzm6z7.js +0 -55
  118. package/dist/cli/index-y2pfmd0z.js +0 -259
  119. package/dist/cli/pending-delegations-37t4xecr.js +0 -34
  120. package/dist/cli/{index-9f71ye47.js → index-13xxjfhn.js} +3 -3
  121. package/dist/cli/{index-s80bsjkj.js → index-2ghkk9ve.js} +6 -6
  122. package/dist/cli/{index-76kvm9z5.js → index-5nybajn9.js} +3 -3
@@ -2,6 +2,15 @@
2
2
  import {
3
3
  readEffectiveSpecSync
4
4
  } from "./index-9ss2m4rs.js";
5
+ import {
6
+ isValidTaskId,
7
+ readTaskEvidence,
8
+ readTaskEvidenceRaw,
9
+ sanitizeTaskId
10
+ } from "./index-wk1h5ec2.js";
11
+ import {
12
+ atomicWriteFile
13
+ } from "./index-dd7ttx8x.js";
5
14
  import {
6
15
  EVIDENCE_MAX_JSON_BYTES,
7
16
  EvidenceBundleSchema,
@@ -29,35 +38,23 @@ import {
29
38
  replayFromLedgerWithStatus,
30
39
  takeSnapshotEvent,
31
40
  takeSnapshotWithRetry
32
- } from "./index-2tn5h2zp.js";
41
+ } from "./index-4p02dp92.js";
33
42
  import {
34
43
  PlanSchema
35
44
  } from "./index-1kz6da87.js";
45
+ import {
46
+ getWorktreeMergeFailure
47
+ } from "./index-b8zgtz81.js";
36
48
  import {
37
49
  readSwarmFileAsync,
38
50
  validateSwarmPath
39
- } from "./index-s80bsjkj.js";
40
- import {
41
- criticalWarn,
42
- error,
43
- init_logger,
44
- warn
45
- } from "./index-zgwm4ryv.js";
46
- import {
47
- isValidTaskId,
48
- readTaskEvidence,
49
- readTaskEvidenceRaw,
50
- sanitizeTaskId
51
- } from "./index-3x761jqv.js";
52
- import {
53
- atomicWriteFile
54
- } from "./index-7mkpsw6g.js";
51
+ } from "./index-2ghkk9ve.js";
55
52
  import {
56
53
  readCachedParsedFile
57
54
  } from "./index-fsrp8wp3.js";
58
55
  import {
59
56
  withEvidenceLock
60
- } from "./index-76kvm9z5.js";
57
+ } from "./index-5nybajn9.js";
61
58
  import {
62
59
  emit
63
60
  } from "./index-q2rrv0cy.js";
@@ -71,6 +68,12 @@ import {
71
68
  bunWrite,
72
69
  mergeEnvForChild
73
70
  } from "./index-qe3v54nb.js";
71
+ import {
72
+ criticalWarn,
73
+ error,
74
+ init_logger,
75
+ warn
76
+ } from "./index-zgwm4ryv.js";
74
77
  import {
75
78
  __esm,
76
79
  __export,
@@ -966,17 +969,17 @@ var init_executor = __esm(() => {
966
969
  import {
967
970
  closeSync,
968
971
  copyFileSync,
969
- existsSync as existsSync4,
972
+ existsSync as existsSync3,
970
973
  fsyncSync,
971
- mkdirSync as mkdirSync4,
974
+ mkdirSync as mkdirSync3,
972
975
  openSync,
973
976
  readdirSync,
974
- renameSync as renameSync3,
975
- unlinkSync as unlinkSync3,
976
- writeFileSync as writeFileSync5
977
+ renameSync as renameSync2,
978
+ unlinkSync as unlinkSync2,
979
+ writeFileSync as writeFileSync4
977
980
  } from "fs";
978
981
  import * as fsPromises from "fs/promises";
979
- import * as path8 from "path";
982
+ import * as path7 from "path";
980
983
 
981
984
  // src/git/branch.ts
982
985
  init_executor();
@@ -1582,65 +1585,18 @@ var _internals5 = {
1582
1585
  readLaneEnvFileFromDiskSync
1583
1586
  };
1584
1587
 
1585
- // src/hooks/delegation-gate/worktree-merge-status.ts
1586
- import * as fs2 from "fs";
1587
- import * as path5 from "path";
1588
- var failuresByTask = new Map;
1589
- var durableStatusPath;
1590
- var hasLoaded = false;
1591
- function loadDurableStatus(statusPath) {
1592
- try {
1593
- hasLoaded = true;
1594
- if (!fs2.existsSync(statusPath)) {
1595
- failuresByTask.clear();
1596
- return;
1597
- }
1598
- const data = JSON.parse(fs2.readFileSync(statusPath, "utf-8"));
1599
- if (data && typeof data === "object") {
1600
- failuresByTask.clear();
1601
- for (const [taskId, failure] of Object.entries(data)) {
1602
- failuresByTask.set(taskId, failure);
1603
- }
1604
- }
1605
- } catch {
1606
- failuresByTask.clear();
1607
- }
1608
- }
1609
- function initDurableStatusPath(projectDir) {
1610
- if (typeof projectDir !== "string" || projectDir.length === 0)
1611
- return;
1612
- const nextPath = path5.join(projectDir, ".swarm", "worktree-merge-status.json");
1613
- if (durableStatusPath === nextPath && hasLoaded)
1614
- return;
1615
- durableStatusPath = nextPath;
1616
- hasLoaded = false;
1617
- loadDurableStatus(durableStatusPath);
1618
- }
1619
- function getWorktreeMergeFailure(taskId) {
1620
- if (!hasLoaded && durableStatusPath) {
1621
- loadDurableStatus(durableStatusPath);
1622
- }
1623
- return failuresByTask.get(taskId);
1624
- }
1625
- function getAllWorktreeMergeFailures() {
1626
- if (!hasLoaded && durableStatusPath) {
1627
- loadDurableStatus(durableStatusPath);
1628
- }
1629
- return failuresByTask.entries();
1630
- }
1631
-
1632
1588
  // src/turbo/epic/state.ts
1633
1589
  init_logger();
1634
- import * as fs3 from "fs";
1635
- import * as path6 from "path";
1590
+ import * as fs2 from "fs";
1591
+ import * as path5 from "path";
1636
1592
  var STATE_FILE = "epic-state.json";
1637
1593
  function nowISO() {
1638
1594
  return new Date().toISOString();
1639
1595
  }
1640
1596
  function ensureSwarmDir(directory) {
1641
- const swarmDir = path6.resolve(directory, ".swarm");
1642
- if (!fs3.existsSync(swarmDir)) {
1643
- fs3.mkdirSync(swarmDir, { recursive: true });
1597
+ const swarmDir = path5.resolve(directory, ".swarm");
1598
+ if (!fs2.existsSync(swarmDir)) {
1599
+ fs2.mkdirSync(swarmDir, { recursive: true });
1644
1600
  }
1645
1601
  return swarmDir;
1646
1602
  }
@@ -1660,17 +1616,17 @@ function markStateUnreadable(directory, reason) {
1660
1616
  }
1661
1617
  function readPersisted(directory) {
1662
1618
  try {
1663
- const filePath = path6.join(directory, ".swarm", STATE_FILE);
1664
- if (!fs3.existsSync(filePath)) {
1619
+ const filePath = path5.join(directory, ".swarm", STATE_FILE);
1620
+ if (!fs2.existsSync(filePath)) {
1665
1621
  const seed = emptyPersisted();
1666
1622
  try {
1667
1623
  ensureSwarmDir(directory);
1668
- fs3.writeFileSync(filePath, `${JSON.stringify(seed, null, 2)}
1624
+ fs2.writeFileSync(filePath, `${JSON.stringify(seed, null, 2)}
1669
1625
  `, "utf-8");
1670
1626
  } catch {}
1671
1627
  return seed;
1672
1628
  }
1673
- const raw = fs3.readFileSync(filePath, "utf-8");
1629
+ const raw = fs2.readFileSync(filePath, "utf-8");
1674
1630
  const parsed = JSON.parse(raw);
1675
1631
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || parsed.version !== 1 || !parsed.sessions || typeof parsed.sessions !== "object" || Array.isArray(parsed.sessions)) {
1676
1632
  markStateUnreadable(directory, `malformed shape (version=${parsed?.version}, sessions type=${Array.isArray(parsed?.sessions) ? "array" : typeof parsed?.sessions})`);
@@ -1696,7 +1652,7 @@ function writePersisted(directory, persisted) {
1696
1652
  let payload;
1697
1653
  try {
1698
1654
  ensureSwarmDir(directory);
1699
- filePath = path6.join(directory, ".swarm", STATE_FILE);
1655
+ filePath = path5.join(directory, ".swarm", STATE_FILE);
1700
1656
  tmpPath = `${filePath}.tmp.${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
1701
1657
  persisted.updatedAt = nowISO();
1702
1658
  payload = `${JSON.stringify(persisted, null, 2)}
@@ -1707,14 +1663,14 @@ function writePersisted(directory, persisted) {
1707
1663
  throw new Error(`Epic state persistence prepare failed: ${msg}`);
1708
1664
  }
1709
1665
  try {
1710
- fs3.writeFileSync(tmpPath, payload, "utf-8");
1711
- fs3.renameSync(tmpPath, filePath);
1666
+ fs2.writeFileSync(tmpPath, payload, "utf-8");
1667
+ fs2.renameSync(tmpPath, filePath);
1712
1668
  } catch (error2) {
1713
1669
  const msg = error2 instanceof Error ? error2.message : String(error2);
1714
1670
  error(`[turbo/epic/state] Failed to persist ${STATE_FILE} atomically: ${msg}`);
1715
1671
  try {
1716
- if (fs3.existsSync(tmpPath))
1717
- fs3.unlinkSync(tmpPath);
1672
+ if (fs2.existsSync(tmpPath))
1673
+ fs2.unlinkSync(tmpPath);
1718
1674
  } catch {}
1719
1675
  throw new Error(`Epic state persistence failed: ${msg}`);
1720
1676
  }
@@ -1745,7 +1701,7 @@ function isEpicModeActive(directory, sessionID) {
1745
1701
  function isEpicModeActiveForProject(directory) {
1746
1702
  if (stateUnreadableMap.get(directory))
1747
1703
  return false;
1748
- if (!fs3.existsSync(path6.join(directory, ".swarm", STATE_FILE))) {
1704
+ if (!fs2.existsSync(path5.join(directory, ".swarm", STATE_FILE))) {
1749
1705
  return false;
1750
1706
  }
1751
1707
  const persisted = readPersisted(directory);
@@ -1871,8 +1827,8 @@ var _internals6 = {
1871
1827
  };
1872
1828
 
1873
1829
  // src/turbo/lean/conflicts.ts
1874
- import * as fs4 from "fs";
1875
- import * as path7 from "path";
1830
+ import * as fs3 from "fs";
1831
+ import * as path6 from "path";
1876
1832
 
1877
1833
  // src/utils/path.ts
1878
1834
  function normalizePath(p) {
@@ -2000,12 +1956,12 @@ function isProtectedPath(normalizedPath) {
2000
1956
  return false;
2001
1957
  }
2002
1958
  function readTaskScopes(directory, taskId) {
2003
- const scopePath = path7.join(directory, ".swarm", "scopes", `scope-${taskId}.json`);
1959
+ const scopePath = path6.join(directory, ".swarm", "scopes", `scope-${taskId}.json`);
2004
1960
  try {
2005
- if (!fs4.existsSync(scopePath)) {
1961
+ if (!fs3.existsSync(scopePath)) {
2006
1962
  return null;
2007
1963
  }
2008
- const raw = fs4.readFileSync(scopePath, "utf-8");
1964
+ const raw = fs3.readFileSync(scopePath, "utf-8");
2009
1965
  const parsed = JSON.parse(raw);
2010
1966
  if (!parsed || !Array.isArray(parsed.files)) {
2011
1967
  return null;
@@ -2019,7 +1975,7 @@ function readTaskScopes(directory, taskId) {
2019
1975
  // src/utils/spec-hash.ts
2020
1976
  import { createHash } from "crypto";
2021
1977
  import * as fsSync2 from "fs";
2022
- import { join as join6 } from "path";
1978
+ import { join as join5 } from "path";
2023
1979
  async function computeSpecHash(directory) {
2024
1980
  const spec = _internals7.readEffectiveSpecSync(directory);
2025
1981
  if (!spec)
@@ -2048,7 +2004,7 @@ async function isSpecStale(directory, plan) {
2048
2004
  return { stale: false };
2049
2005
  }
2050
2006
  function isObligationPreserving(directory) {
2051
- const snapshotPath = join6(directory, ".swarm", "spec-snapshot.md");
2007
+ const snapshotPath = join5(directory, ".swarm", "spec-snapshot.md");
2052
2008
  try {
2053
2009
  let recordedContent;
2054
2010
  try {
@@ -2094,7 +2050,7 @@ var _internals7 = {
2094
2050
  readEffectiveSpecSync
2095
2051
  };
2096
2052
  function computeSpecDiff(directory) {
2097
- const snapshotPath = join6(directory, ".swarm", "spec-snapshot.md");
2053
+ const snapshotPath = join5(directory, ".swarm", "spec-snapshot.md");
2098
2054
  let recordedContent;
2099
2055
  try {
2100
2056
  const snapshotSize = fsSync2.statSync(snapshotPath).size;
@@ -2340,7 +2296,7 @@ async function getLatestLedgerHash(directory) {
2340
2296
  }
2341
2297
  }
2342
2298
  async function surfaceLedgerStaleIfPersisted(directory, plan) {
2343
- const resolvedWorkspace = path8.resolve(directory);
2299
+ const resolvedWorkspace = path7.resolve(directory);
2344
2300
  if (!ledgerStaleWorkspaces.has(resolvedWorkspace)) {
2345
2301
  return plan;
2346
2302
  }
@@ -2359,7 +2315,7 @@ async function surfaceLedgerStaleIfPersisted(directory, plan) {
2359
2315
  return plan;
2360
2316
  }
2361
2317
  async function parsePlanJsonCached(directory) {
2362
- const planJsonPath = path8.resolve(directory, ".swarm", "plan.json");
2318
+ const planJsonPath = path7.resolve(directory, ".swarm", "plan.json");
2363
2319
  return readCachedParsedFile(planJsonPath, PLAN_JSON_CACHE_NAMESPACE, () => readSwarmFileAsync(directory, "plan.json"), (planJsonContent) => {
2364
2320
  if (planJsonContent.includes("\x00") || planJsonContent.includes("\uFFFD")) {
2365
2321
  throw new Error("Plan rejected: .swarm/plan.json contains null bytes or invalid encoding");
@@ -2419,19 +2375,19 @@ async function isPlanMdInSync(directory, plan, cache) {
2419
2375
  return false;
2420
2376
  }
2421
2377
  async function regeneratePlanMarkdown(directory, plan) {
2422
- const swarmDir = path8.resolve(directory, ".swarm");
2378
+ const swarmDir = path7.resolve(directory, ".swarm");
2423
2379
  const contentHash = computePlanContentHash(plan);
2424
2380
  const markdown = derivePlanMarkdown(plan);
2425
2381
  const markdownWithHash = `<!-- PLAN_HASH: ${contentHash} -->
2426
2382
  ${markdown}`;
2427
- const mdPath = path8.join(swarmDir, "plan.md");
2428
- const mdTempPath = path8.join(swarmDir, `plan.md.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
2383
+ const mdPath = path7.join(swarmDir, "plan.md");
2384
+ const mdTempPath = path7.join(swarmDir, `plan.md.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
2429
2385
  try {
2430
2386
  await bunWrite(mdTempPath, markdownWithHash);
2431
- renameSync3(mdTempPath, mdPath);
2387
+ renameSync2(mdTempPath, mdPath);
2432
2388
  } finally {
2433
2389
  try {
2434
- unlinkSync3(mdTempPath);
2390
+ unlinkSync2(mdTempPath);
2435
2391
  } catch {}
2436
2392
  }
2437
2393
  }
@@ -2457,7 +2413,7 @@ async function loadPlan(directory, cache) {
2457
2413
  if (await ledgerExists(directory)) {
2458
2414
  const planHash = computePlanHash(validated);
2459
2415
  const ledgerHash = await getLatestLedgerHash(directory);
2460
- const resolvedWorkspace = path8.resolve(directory);
2416
+ const resolvedWorkspace = path7.resolve(directory);
2461
2417
  if (!startupLedgerCheckedWorkspaces.has(resolvedWorkspace)) {
2462
2418
  startupLedgerCheckedWorkspaces.add(resolvedWorkspace);
2463
2419
  if (ledgerHash !== "" && planHash !== ledgerHash) {
@@ -2531,7 +2487,7 @@ async function loadPlan(directory, cache) {
2531
2487
  if (!preserving) {
2532
2488
  try {
2533
2489
  const diffInfo = computeSpecDiff(directory);
2534
- const specStalenessPath = path8.join(directory, ".swarm", "spec-staleness.json");
2490
+ const specStalenessPath = path7.join(directory, ".swarm", "spec-staleness.json");
2535
2491
  await fsPromises.writeFile(specStalenessPath, JSON.stringify({
2536
2492
  type: "spec_stale_detected",
2537
2493
  timestamp: new Date().toISOString(),
@@ -2545,7 +2501,7 @@ async function loadPlan(directory, cache) {
2545
2501
  }, null, 2), "utf-8");
2546
2502
  } catch {}
2547
2503
  try {
2548
- const eventsPath = path8.join(directory, ".swarm", "events.jsonl");
2504
+ const eventsPath = path7.join(directory, ".swarm", "events.jsonl");
2549
2505
  const event = {
2550
2506
  type: "spec_stale_detected",
2551
2507
  timestamp: new Date().toISOString(),
@@ -2611,7 +2567,7 @@ async function loadPlan(directory, cache) {
2611
2567
  return migrated;
2612
2568
  }
2613
2569
  if (await ledgerExists(directory)) {
2614
- const resolvedDir = path8.resolve(directory);
2570
+ const resolvedDir = path7.resolve(directory);
2615
2571
  const existingMutex = recoveryMutexes.get(resolvedDir);
2616
2572
  if (existingMutex) {
2617
2573
  await existingMutex;
@@ -2740,13 +2696,13 @@ async function savePlan(directory, plan, options) {
2740
2696
  } else {
2741
2697
  const existingEvents = await readLedgerEvents(directory);
2742
2698
  if (existingEvents.length > 0 && existingEvents[0].plan_id !== planId) {
2743
- const swarmDir2 = path8.resolve(directory, ".swarm");
2744
- const oldLedgerPath = path8.join(swarmDir2, "plan-ledger.jsonl");
2745
- const oldLedgerBackupPath = path8.join(swarmDir2, `plan-ledger.backup-${Date.now()}-${Math.floor(Math.random() * 1e9)}.jsonl`);
2699
+ const swarmDir2 = path7.resolve(directory, ".swarm");
2700
+ const oldLedgerPath = path7.join(swarmDir2, "plan-ledger.jsonl");
2701
+ const oldLedgerBackupPath = path7.join(swarmDir2, `plan-ledger.backup-${Date.now()}-${Math.floor(Math.random() * 1e9)}.jsonl`);
2746
2702
  let backupExists = false;
2747
- if (existsSync4(oldLedgerPath)) {
2703
+ if (existsSync3(oldLedgerPath)) {
2748
2704
  try {
2749
- renameSync3(oldLedgerPath, oldLedgerBackupPath);
2705
+ renameSync2(oldLedgerPath, oldLedgerBackupPath);
2750
2706
  backupExists = true;
2751
2707
  } catch (renameErr) {
2752
2708
  throw new Error(`[savePlan] Cannot reinitialize ledger: could not move old ledger aside (rename failed: ${renameErr instanceof Error ? renameErr.message : String(renameErr)}). The existing ledger has plan_id="${existingEvents[0].plan_id}" which does not match the current plan="${planId}". To proceed, close any programs that may have the ledger file open, or run /swarm reset-session to clear the ledger.`);
@@ -2761,17 +2717,17 @@ async function savePlan(directory, plan, options) {
2761
2717
  const errorMessage2 = String(initErr);
2762
2718
  if (errorMessage2.includes("already initialized")) {
2763
2719
  try {
2764
- if (existsSync4(oldLedgerBackupPath))
2765
- unlinkSync3(oldLedgerBackupPath);
2720
+ if (existsSync3(oldLedgerBackupPath))
2721
+ unlinkSync2(oldLedgerBackupPath);
2766
2722
  } catch {}
2767
2723
  } else {
2768
- if (existsSync4(oldLedgerBackupPath)) {
2724
+ if (existsSync3(oldLedgerBackupPath)) {
2769
2725
  try {
2770
- renameSync3(oldLedgerBackupPath, oldLedgerPath);
2726
+ renameSync2(oldLedgerBackupPath, oldLedgerPath);
2771
2727
  } catch {
2772
2728
  copyFileSync(oldLedgerBackupPath, oldLedgerPath);
2773
2729
  try {
2774
- unlinkSync3(oldLedgerBackupPath);
2730
+ unlinkSync2(oldLedgerBackupPath);
2775
2731
  } catch {}
2776
2732
  }
2777
2733
  }
@@ -2780,21 +2736,21 @@ async function savePlan(directory, plan, options) {
2780
2736
  }
2781
2737
  }
2782
2738
  if (initSucceeded && backupExists) {
2783
- const archivePath = path8.join(swarmDir2, `plan-ledger.archived-${Date.now()}-${Math.floor(Math.random() * 1e9)}.jsonl`);
2739
+ const archivePath = path7.join(swarmDir2, `plan-ledger.archived-${Date.now()}-${Math.floor(Math.random() * 1e9)}.jsonl`);
2784
2740
  try {
2785
- renameSync3(oldLedgerBackupPath, archivePath);
2741
+ renameSync2(oldLedgerBackupPath, archivePath);
2786
2742
  warn(`[savePlan] Ledger identity mismatch (was "${existingEvents[0].plan_id}", now "${planId}") \u2014 archived old ledger to ${archivePath} and reinitializing.`);
2787
2743
  } catch (renameErr) {
2788
2744
  warn(`[savePlan] Could not archive old ledger (rename failed: ${renameErr instanceof Error ? renameErr.message : String(renameErr)}). Old ledger may still exist at ${oldLedgerBackupPath}.`);
2789
2745
  try {
2790
- if (existsSync4(oldLedgerBackupPath))
2791
- unlinkSync3(oldLedgerBackupPath);
2746
+ if (existsSync3(oldLedgerBackupPath))
2747
+ unlinkSync2(oldLedgerBackupPath);
2792
2748
  } catch {}
2793
2749
  }
2794
2750
  } else if (!initSucceeded && backupExists) {
2795
2751
  try {
2796
- if (existsSync4(oldLedgerBackupPath))
2797
- unlinkSync3(oldLedgerBackupPath);
2752
+ if (existsSync3(oldLedgerBackupPath))
2753
+ unlinkSync2(oldLedgerBackupPath);
2798
2754
  } catch {}
2799
2755
  }
2800
2756
  const MAX_ARCHIVED_SIBLINGS = 5;
@@ -2805,7 +2761,7 @@ async function savePlan(directory, plan, options) {
2805
2761
  const toRemove = archivedSiblings.slice(0, archivedSiblings.length - MAX_ARCHIVED_SIBLINGS);
2806
2762
  for (const file of toRemove) {
2807
2763
  try {
2808
- unlinkSync3(path8.join(swarmDir2, file));
2764
+ unlinkSync2(path7.join(swarmDir2, file));
2809
2765
  } catch {}
2810
2766
  }
2811
2767
  }
@@ -2948,19 +2904,19 @@ async function savePlan(directory, plan, options) {
2948
2904
  source: "savePlan_manager"
2949
2905
  });
2950
2906
  }
2951
- const swarmDir = path8.resolve(directory, ".swarm");
2952
- const planPath = path8.join(swarmDir, "plan.json");
2953
- const tempPath = path8.join(swarmDir, `plan.json.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
2907
+ const swarmDir = path7.resolve(directory, ".swarm");
2908
+ const planPath = path7.join(swarmDir, "plan.json");
2909
+ const tempPath = path7.join(swarmDir, `plan.json.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
2954
2910
  try {
2955
2911
  await bunWrite(tempPath, JSON.stringify(projectedPlan, null, 2));
2956
- renameSync3(tempPath, planPath);
2912
+ renameSync2(tempPath, planPath);
2957
2913
  } finally {
2958
2914
  try {
2959
- unlinkSync3(tempPath);
2915
+ unlinkSync2(tempPath);
2960
2916
  } catch {}
2961
2917
  }
2962
2918
  try {
2963
- const markerPath = path8.join(swarmDir, ".plan-write-marker");
2919
+ const markerPath = path7.join(swarmDir, ".plan-write-marker");
2964
2920
  const inProgressMarker = JSON.stringify({
2965
2921
  source: "plan_manager",
2966
2922
  timestamp: new Date().toISOString(),
@@ -2975,14 +2931,14 @@ async function savePlan(directory, plan, options) {
2975
2931
  const markdown = derivePlanMarkdown(projectedPlan);
2976
2932
  const markdownWithHash = `<!-- PLAN_HASH: ${contentHash} -->
2977
2933
  ${markdown}`;
2978
- const mdPath = path8.join(swarmDir, "plan.md");
2979
- const mdTempPath = path8.join(swarmDir, `plan.md.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
2934
+ const mdPath = path7.join(swarmDir, "plan.md");
2935
+ const mdTempPath = path7.join(swarmDir, `plan.md.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
2980
2936
  try {
2981
2937
  await bunWrite(mdTempPath, markdownWithHash);
2982
- renameSync3(mdTempPath, mdPath);
2938
+ renameSync2(mdTempPath, mdPath);
2983
2939
  } finally {
2984
2940
  try {
2985
- unlinkSync3(mdTempPath);
2941
+ unlinkSync2(mdTempPath);
2986
2942
  } catch {}
2987
2943
  }
2988
2944
  } catch (mdError) {
@@ -2997,7 +2953,7 @@ ${markdown}`;
2997
2953
  } catch {}
2998
2954
  }
2999
2955
  try {
3000
- const markerPath = path8.join(swarmDir, ".plan-write-marker");
2956
+ const markerPath = path7.join(swarmDir, ".plan-write-marker");
3001
2957
  const tasksCount = projectedPlan.phases.reduce((sum, phase) => sum + phase.tasks.length, 0);
3002
2958
  const marker = JSON.stringify({
3003
2959
  source: "plan_manager",
@@ -3013,23 +2969,23 @@ async function rebuildPlan(directory, plan, options) {
3013
2969
  const targetPlan = plan ?? await replayFromLedger(directory);
3014
2970
  if (!targetPlan)
3015
2971
  return null;
3016
- const swarmDir = path8.join(directory, ".swarm");
3017
- const planPath = path8.join(swarmDir, "plan.json");
3018
- const mdPath = path8.join(swarmDir, "plan.md");
3019
- mkdirSync4(swarmDir, { recursive: true });
3020
- const tempPlanPath = path8.join(swarmDir, `plan.json.rebuild.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
2972
+ const swarmDir = path7.join(directory, ".swarm");
2973
+ const planPath = path7.join(swarmDir, "plan.json");
2974
+ const mdPath = path7.join(swarmDir, "plan.md");
2975
+ mkdirSync3(swarmDir, { recursive: true });
2976
+ const tempPlanPath = path7.join(swarmDir, `plan.json.rebuild.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
3021
2977
  {
3022
2978
  const fd = openSync(tempPlanPath, "w");
3023
2979
  try {
3024
- writeFileSync5(fd, JSON.stringify(targetPlan, null, 2), "utf8");
2980
+ writeFileSync4(fd, JSON.stringify(targetPlan, null, 2), "utf8");
3025
2981
  fsyncSync(fd);
3026
2982
  } finally {
3027
2983
  closeSync(fd);
3028
2984
  }
3029
2985
  }
3030
- renameSync3(tempPlanPath, planPath);
2986
+ renameSync2(tempPlanPath, planPath);
3031
2987
  try {
3032
- const markerPath = path8.join(swarmDir, ".plan-write-marker");
2988
+ const markerPath = path7.join(swarmDir, ".plan-write-marker");
3033
2989
  const inProgressMarker = JSON.stringify({
3034
2990
  source: "plan_manager",
3035
2991
  timestamp: new Date().toISOString(),
@@ -3044,12 +3000,12 @@ async function rebuildPlan(directory, plan, options) {
3044
3000
  const markdown = derivePlanMarkdown(targetPlan);
3045
3001
  const markdownWithHash = `<!-- PLAN_HASH: ${contentHash} -->
3046
3002
  ${markdown}`;
3047
- const tempMdPath = path8.join(swarmDir, `plan.md.rebuild.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
3003
+ const tempMdPath = path7.join(swarmDir, `plan.md.rebuild.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
3048
3004
  await bunWrite(tempMdPath, markdownWithHash);
3049
- renameSync3(tempMdPath, mdPath);
3005
+ renameSync2(tempMdPath, mdPath);
3050
3006
  } finally {
3051
3007
  try {
3052
- const markerPath = path8.join(swarmDir, ".plan-write-marker");
3008
+ const markerPath = path7.join(swarmDir, ".plan-write-marker");
3053
3009
  const tasksCount = targetPlan.phases.reduce((sum, phase) => sum + phase.tasks.length, 0);
3054
3010
  const marker = JSON.stringify({
3055
3011
  source: "plan_manager",
@@ -3112,13 +3068,13 @@ async function closePlanTerminalState(directory, plan, options) {
3112
3068
  planHashAfter: hashAfter,
3113
3069
  source: "close_terminal"
3114
3070
  });
3115
- const swarmDir = path8.join(directory, ".swarm");
3116
- const planPath = path8.join(swarmDir, "plan.json");
3117
- const tempPlanPath = path8.join(swarmDir, `plan.json.close.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
3071
+ const swarmDir = path7.join(directory, ".swarm");
3072
+ const planPath = path7.join(swarmDir, "plan.json");
3073
+ const tempPlanPath = path7.join(swarmDir, `plan.json.close.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
3118
3074
  await bunWrite(tempPlanPath, JSON.stringify(validated, null, 2));
3119
- renameSync3(tempPlanPath, planPath);
3075
+ renameSync2(tempPlanPath, planPath);
3120
3076
  try {
3121
- const markerPath = path8.join(swarmDir, ".plan-write-marker");
3077
+ const markerPath = path7.join(swarmDir, ".plan-write-marker");
3122
3078
  const inProgressMarker = JSON.stringify({
3123
3079
  source: "plan_manager_close",
3124
3080
  timestamp: new Date().toISOString(),
@@ -3129,17 +3085,17 @@ async function closePlanTerminalState(directory, plan, options) {
3129
3085
  await bunWrite(markerPath, inProgressMarker);
3130
3086
  } catch {}
3131
3087
  try {
3132
- const mdPath = path8.join(swarmDir, "plan.md");
3088
+ const mdPath = path7.join(swarmDir, "plan.md");
3133
3089
  const contentHash = computePlanContentHash(validated);
3134
3090
  const markdown = derivePlanMarkdown(validated);
3135
3091
  const markdownWithHash = `<!-- PLAN_HASH: ${contentHash} -->
3136
3092
  ${markdown}`;
3137
- const mdTempPath = path8.join(swarmDir, `plan.md.close.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
3093
+ const mdTempPath = path7.join(swarmDir, `plan.md.close.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
3138
3094
  await bunWrite(mdTempPath, markdownWithHash);
3139
- renameSync3(mdTempPath, mdPath);
3095
+ renameSync2(mdTempPath, mdPath);
3140
3096
  } finally {
3141
3097
  try {
3142
- const markerPath = path8.join(swarmDir, ".plan-write-marker");
3098
+ const markerPath = path7.join(swarmDir, ".plan-write-marker");
3143
3099
  const tasksCount = validated.phases.reduce((sum, phase) => sum + phase.tasks.length, 0);
3144
3100
  const marker = JSON.stringify({
3145
3101
  source: "plan_manager_close",
@@ -3424,19 +3380,19 @@ function migrateLegacyPlan(planContent, swarmId) {
3424
3380
  // src/evidence/manager.ts
3425
3381
  init_zod();
3426
3382
  import {
3427
- mkdirSync as mkdirSync5,
3383
+ mkdirSync as mkdirSync4,
3428
3384
  readdirSync as readdirSync2,
3429
3385
  realpathSync as realpathSync2,
3430
3386
  rmSync,
3431
3387
  statSync as statSync2
3432
3388
  } from "fs";
3433
- import * as fs7 from "fs/promises";
3389
+ import * as fs6 from "fs/promises";
3434
3390
  import * as os4 from "os";
3435
- import * as path13 from "path";
3391
+ import * as path12 from "path";
3436
3392
 
3437
3393
  // src/evaluation/retention.ts
3438
- import * as fs5 from "fs/promises";
3439
- import * as path12 from "path";
3394
+ import * as fs4 from "fs/promises";
3395
+ import * as path11 from "path";
3440
3396
 
3441
3397
  // src/evaluation/contracts.ts
3442
3398
  init_zod();
@@ -3812,11 +3768,11 @@ var TaskSetSnapshotV1Schema = exports_external.object({
3812
3768
 
3813
3769
  // src/evaluation/store.ts
3814
3770
  import { mkdir as mkdir2, readdir, readFile as readFile3 } from "fs/promises";
3815
- import * as path11 from "path";
3771
+ import * as path10 from "path";
3816
3772
 
3817
3773
  // src/evidence/immutable-store.ts
3818
3774
  import { mkdir, readFile } from "fs/promises";
3819
- import * as path9 from "path";
3775
+ import * as path8 from "path";
3820
3776
  async function readOptionalFile(filePath) {
3821
3777
  try {
3822
3778
  return await readFile(filePath, "utf8");
@@ -3827,7 +3783,7 @@ async function readOptionalFile(filePath) {
3827
3783
  }
3828
3784
  }
3829
3785
  async function writeImmutableArtifact(options) {
3830
- await mkdir(path9.dirname(options.filePath), { recursive: true });
3786
+ await mkdir(path8.dirname(options.filePath), { recursive: true });
3831
3787
  return withEvidenceLock(options.directory, options.relativeLockPath, options.agent, options.taskId, async () => {
3832
3788
  const desired = options.serialize(options.value);
3833
3789
  const existing = await readOptionalFile(options.filePath);
@@ -3859,7 +3815,7 @@ async function writeImmutableArtifact(options) {
3859
3815
  import { createHash as createHash2 } from "crypto";
3860
3816
  import { lstatSync, realpathSync } from "fs";
3861
3817
  import { lstat, opendir, readFile as readFile2, realpath } from "fs/promises";
3862
- import * as path10 from "path";
3818
+ import * as path9 from "path";
3863
3819
  function canonicalize(value, ancestors) {
3864
3820
  if (value === null || typeof value === "string" || typeof value === "boolean") {
3865
3821
  return value;
@@ -3950,7 +3906,7 @@ async function hashTree(projectRoot, relativePath, budget) {
3950
3906
  }
3951
3907
  if (!entryAlreadyCharged)
3952
3908
  chargeHashEntry(budget);
3953
- const relative2 = path10.relative(canonicalRoot, absolutePath).replace(/\\/g, "/");
3909
+ const relative2 = path9.relative(canonicalRoot, absolutePath).replace(/\\/g, "/");
3954
3910
  if (stat.isDirectory()) {
3955
3911
  entries.push({ path: relative2, type: "directory" });
3956
3912
  const children = [];
@@ -3967,7 +3923,7 @@ async function hashTree(projectRoot, relativePath, budget) {
3967
3923
  await closeDirectory(directory);
3968
3924
  }
3969
3925
  for (const child of children.sort()) {
3970
- await visit(path10.join(absolutePath, child), true);
3926
+ await visit(path9.join(absolutePath, child), true);
3971
3927
  }
3972
3928
  return;
3973
3929
  }
@@ -4010,10 +3966,10 @@ async function computeTaskLineageInputHash(projectRoot, task, limits = {}) {
4010
3966
  const normalizedTree = async (relativePath) => {
4011
3967
  const canonicalRoot = await _internals9.realpath(projectRoot);
4012
3968
  const target = await resolveContainedExistingPathAsync(projectRoot, relativePath);
4013
- const targetRelative = path10.relative(canonicalRoot, target).replace(/\\/g, "/");
3969
+ const targetRelative = path9.relative(canonicalRoot, target).replace(/\\/g, "/");
4014
3970
  return (await hashTree(projectRoot, relativePath, budget)).map((entry) => ({
4015
3971
  ...entry,
4016
- path: path10.posix.relative(targetRelative, entry.path) || "."
3972
+ path: path9.posix.relative(targetRelative, entry.path) || "."
4017
3973
  }));
4018
3974
  };
4019
3975
  const scorerArgv = [...task.scorer.argv];
@@ -4042,11 +3998,11 @@ function computeManifestContentHash(manifest) {
4042
3998
  return contentHashWithout(manifest, ["contentHash"]);
4043
3999
  }
4044
4000
  function isWithin(root, candidate) {
4045
- const relative2 = path10.relative(root, candidate);
4046
- return relative2 === "" || !relative2.startsWith("..") && !path10.isAbsolute(relative2);
4001
+ const relative2 = path9.relative(root, candidate);
4002
+ return relative2 === "" || !relative2.startsWith("..") && !path9.isAbsolute(relative2);
4047
4003
  }
4048
4004
  function resolveContainedExistingPath(root, relativePath) {
4049
- if (path10.isAbsolute(relativePath) || /^(?:[A-Za-z]:[\\/]|[\\/]{1,2})/.test(relativePath) || relativePath.includes("\x00")) {
4005
+ if (path9.isAbsolute(relativePath) || /^(?:[A-Za-z]:[\\/]|[\\/]{1,2})/.test(relativePath) || relativePath.includes("\x00")) {
4050
4006
  throw new Error("evaluation path must be a non-NUL relative path");
4051
4007
  }
4052
4008
  const segments = relativePath.replace(/\\/g, "/").split("/").filter(Boolean);
@@ -4058,7 +4014,7 @@ function resolveContainedExistingPath(root, relativePath) {
4058
4014
  for (const segment of segments) {
4059
4015
  if (segment === ".")
4060
4016
  continue;
4061
- cursor = path10.join(cursor, segment);
4017
+ cursor = path9.join(cursor, segment);
4062
4018
  const stat = lstatSync(cursor);
4063
4019
  if (stat.isSymbolicLink()) {
4064
4020
  throw new Error(`evaluation path contains a symlink or reparse point: ${relativePath}`);
@@ -4071,7 +4027,7 @@ function resolveContainedExistingPath(root, relativePath) {
4071
4027
  return canonicalCandidate;
4072
4028
  }
4073
4029
  async function resolveContainedExistingPathAsync(root, relativePath) {
4074
- if (path10.isAbsolute(relativePath) || /^(?:[A-Za-z]:[\\/]|[\\/]{1,2})/.test(relativePath) || relativePath.includes("\x00")) {
4030
+ if (path9.isAbsolute(relativePath) || /^(?:[A-Za-z]:[\\/]|[\\/]{1,2})/.test(relativePath) || relativePath.includes("\x00")) {
4075
4031
  throw new Error("evaluation path must be a non-NUL relative path");
4076
4032
  }
4077
4033
  const segments = relativePath.replace(/\\/g, "/").split("/").filter(Boolean);
@@ -4083,7 +4039,7 @@ async function resolveContainedExistingPathAsync(root, relativePath) {
4083
4039
  for (const segment of segments) {
4084
4040
  if (segment === ".")
4085
4041
  continue;
4086
- cursor = path10.join(cursor, segment);
4042
+ cursor = path9.join(cursor, segment);
4087
4043
  const stat = await _internals9.lstat(cursor);
4088
4044
  if (stat.isSymbolicLink()) {
4089
4045
  throw new Error(`evaluation path contains a symlink or reparse point: ${relativePath}`);
@@ -4104,8 +4060,8 @@ var _internals9 = {
4104
4060
 
4105
4061
  // src/evaluation/store.ts
4106
4062
  var AGENT = "evaluation-store";
4107
- var TEST_LEDGER_RELATIVE = path11.join("evolution", "test-consumption.jsonl");
4108
- var TASK_SPLIT_REGISTRY_RELATIVE = path11.join("evolution", "tasks", "split-registry.json");
4063
+ var TEST_LEDGER_RELATIVE = path10.join("evolution", "test-consumption.jsonl");
4064
+ var TASK_SPLIT_REGISTRY_RELATIVE = path10.join("evolution", "tasks", "split-registry.json");
4109
4065
 
4110
4066
  class EvaluationConflictError extends Error {
4111
4067
  constructor(message) {
@@ -4114,7 +4070,7 @@ class EvaluationConflictError extends Error {
4114
4070
  }
4115
4071
  }
4116
4072
  function swarmPath(directory, ...segments) {
4117
- return path11.join(directory, ".swarm", ...segments);
4073
+ return path10.join(directory, ".swarm", ...segments);
4118
4074
  }
4119
4075
  function serialized(value) {
4120
4076
  return `${canonicalJson(value)}
@@ -4172,8 +4128,8 @@ function validateTaskInputs(directory, task) {
4172
4128
  if (!executable)
4173
4129
  throw new Error("project scorer requires an executable");
4174
4130
  const scorerPath = resolveContainedExistingPath(directory, executable);
4175
- const relative3 = path11.relative(environmentRoot, scorerPath);
4176
- if (!relative3 || relative3 === ".." || relative3.startsWith(`..${path11.sep}`) || path11.isAbsolute(relative3)) {
4131
+ const relative3 = path10.relative(environmentRoot, scorerPath);
4132
+ if (!relative3 || relative3 === ".." || relative3.startsWith(`..${path10.sep}`) || path10.isAbsolute(relative3)) {
4177
4133
  throw new Error("project scorer executable must be inside the admitted task environment");
4178
4134
  }
4179
4135
  }
@@ -4185,10 +4141,10 @@ async function admitEvaluationTask(directory, input, inputRoot = directory) {
4185
4141
  }
4186
4142
  validateTaskInputs(inputRoot, task);
4187
4143
  const lineageInputHash = await computeTaskLineageInputHash(inputRoot, task);
4188
- const relative3 = path11.join("evolution", "tasks", task.split, `${task.id}.json`);
4144
+ const relative3 = path10.join("evolution", "tasks", task.split, `${task.id}.json`);
4189
4145
  const admissionLock = TASK_SPLIT_REGISTRY_RELATIVE;
4190
4146
  const filePath = swarmPath(directory, relative3);
4191
- await mkdir2(path11.dirname(filePath), { recursive: true });
4147
+ await mkdir2(path10.dirname(filePath), { recursive: true });
4192
4148
  return withEvidenceLock(directory, admissionLock, AGENT, task.id, async () => {
4193
4149
  const registryPath = swarmPath(directory, TASK_SPLIT_REGISTRY_RELATIVE);
4194
4150
  const registry = parseTaskSplitRegistry(await readOptionalFile(registryPath));
@@ -4276,7 +4232,7 @@ async function saveTaskSetSnapshot(directory, input, inputRoot = directory) {
4276
4232
  if (computeTaskSetContentHash(snapshot) !== snapshot.contentHash) {
4277
4233
  throw new Error("task-set content hash does not match its canonical inputs");
4278
4234
  }
4279
- const relative3 = path11.join("evolution", "task-sets", `${snapshot.contentHash}.json`);
4235
+ const relative3 = path10.join("evolution", "task-sets", `${snapshot.contentHash}.json`);
4280
4236
  return writeImmutable({
4281
4237
  directory,
4282
4238
  relativeLockPath: relative3,
@@ -4289,7 +4245,7 @@ async function saveTaskSetSnapshot(directory, input, inputRoot = directory) {
4289
4245
  }
4290
4246
  async function saveGateAuditResult(directory, input) {
4291
4247
  const result = GateAuditResultV1Schema.parse(input);
4292
- const relative3 = path11.join("evidence", "gate-audit", result.runId, "results.json");
4248
+ const relative3 = path10.join("evidence", "gate-audit", result.runId, "results.json");
4293
4249
  return writeImmutable({
4294
4250
  directory,
4295
4251
  relativeLockPath: relative3,
@@ -4301,7 +4257,7 @@ async function saveGateAuditResult(directory, input) {
4301
4257
  }
4302
4258
  async function saveGateAuditManifest(directory, input) {
4303
4259
  const manifest = GateAuditManifestV1Schema.parse(input);
4304
- const relative3 = path11.join("evolution", "gate-audit-manifests", `${manifest.id}.json`);
4260
+ const relative3 = path10.join("evolution", "gate-audit-manifests", `${manifest.id}.json`);
4305
4261
  return writeImmutable({
4306
4262
  directory,
4307
4263
  relativeLockPath: relative3,
@@ -4337,7 +4293,7 @@ async function listGateAuditResults(directory) {
4337
4293
  continue;
4338
4294
  }
4339
4295
  try {
4340
- const parsed = GateAuditResultV1Schema.parse(JSON.parse(await readFile3(path11.join(root, entry.name, "results.json"), "utf8")));
4296
+ const parsed = GateAuditResultV1Schema.parse(JSON.parse(await readFile3(path10.join(root, entry.name, "results.json"), "utf8")));
4341
4297
  if (parsed.runId !== entry.name)
4342
4298
  throw new Error("run id/path mismatch");
4343
4299
  results.push(parsed);
@@ -4370,7 +4326,7 @@ async function getProtectedEvaluationRunIds(directory) {
4370
4326
  throw error2;
4371
4327
  }
4372
4328
  for (const filename of files.filter((value) => value.endsWith(".json")).sort()) {
4373
- const decision = PromotionDecisionV1Schema.parse(JSON.parse(await readFile3(path11.join(decisionsDirectory, filename), "utf8")));
4329
+ const decision = PromotionDecisionV1Schema.parse(JSON.parse(await readFile3(path10.join(decisionsDirectory, filename), "utf8")));
4374
4330
  protectedIds.add(decision.runId);
4375
4331
  protectedIds.add(decision.lineage.baselineRunId);
4376
4332
  if (decision.lineage.historicalBestRunId !== "unavailable") {
@@ -4388,10 +4344,10 @@ function validId(value) {
4388
4344
  return /^[A-Za-z0-9][A-Za-z0-9._-]{0,159}$/.test(value);
4389
4345
  }
4390
4346
  async function evaluationRunCandidates(directory) {
4391
- const root = path12.join(directory, ".swarm", "evolution", "runs");
4347
+ const root = path11.join(directory, ".swarm", "evolution", "runs");
4392
4348
  let entries = [];
4393
4349
  try {
4394
- entries = await fs5.readdir(root, { withFileTypes: true });
4350
+ entries = await fs4.readdir(root, { withFileTypes: true });
4395
4351
  } catch (error2) {
4396
4352
  if (error2.code === "ENOENT") {
4397
4353
  return { candidates: [], corrupt: [] };
@@ -4407,9 +4363,9 @@ async function evaluationRunCandidates(directory) {
4407
4363
  if (!validId(id))
4408
4364
  continue;
4409
4365
  const artifact = { namespace: "evaluation-run", id };
4410
- const target = path12.join(root, entry.name);
4366
+ const target = path11.join(root, entry.name);
4411
4367
  try {
4412
- const run = EvaluationRunV1Schema.parse(JSON.parse(await fs5.readFile(target, "utf8")));
4368
+ const run = EvaluationRunV1Schema.parse(JSON.parse(await fs4.readFile(target, "utf8")));
4413
4369
  if (run.runId !== id)
4414
4370
  throw new Error("run id/path mismatch");
4415
4371
  candidates.push({
@@ -4425,10 +4381,10 @@ async function evaluationRunCandidates(directory) {
4425
4381
  return { candidates, corrupt };
4426
4382
  }
4427
4383
  async function gateAuditCandidates(directory) {
4428
- const root = path12.join(directory, ".swarm", "evidence", "gate-audit");
4384
+ const root = path11.join(directory, ".swarm", "evidence", "gate-audit");
4429
4385
  let entries = [];
4430
4386
  try {
4431
- entries = await fs5.readdir(root, { withFileTypes: true });
4387
+ entries = await fs4.readdir(root, { withFileTypes: true });
4432
4388
  } catch (error2) {
4433
4389
  if (error2.code === "ENOENT") {
4434
4390
  return { candidates: [], corrupt: [] };
@@ -4441,9 +4397,9 @@ async function gateAuditCandidates(directory) {
4441
4397
  if (!entry.isDirectory() || !validId(entry.name))
4442
4398
  continue;
4443
4399
  const artifact = { namespace: "gate-audit", id: entry.name };
4444
- const target = path12.join(root, entry.name);
4400
+ const target = path11.join(root, entry.name);
4445
4401
  try {
4446
- const result = GateAuditResultV1Schema.parse(JSON.parse(await fs5.readFile(path12.join(target, "results.json"), "utf8")));
4402
+ const result = GateAuditResultV1Schema.parse(JSON.parse(await fs4.readFile(path11.join(target, "results.json"), "utf8")));
4447
4403
  if (result.runId !== entry.name)
4448
4404
  throw new Error("run id/path mismatch");
4449
4405
  candidates.push({
@@ -4474,17 +4430,17 @@ async function protectedArtifacts(directory) {
4474
4430
  }
4475
4431
  async function removeCandidate(candidate) {
4476
4432
  if (candidate.kind === "directory") {
4477
- await fs5.rm(candidate.target, { recursive: true, force: true });
4433
+ await fs4.rm(candidate.target, { recursive: true, force: true });
4478
4434
  return;
4479
4435
  }
4480
- await fs5.unlink(candidate.target);
4436
+ await fs4.unlink(candidate.target);
4481
4437
  }
4482
4438
  var _retentionInternals = {
4483
4439
  protectedArtifacts,
4484
4440
  removeCandidate
4485
4441
  };
4486
4442
  async function archiveEvaluationArtifacts(args) {
4487
- return withEvidenceLock(args.directory, path12.join("evolution", "retention-index"), "evaluation-retention", "archive", async () => {
4443
+ return withEvidenceLock(args.directory, path11.join("evolution", "retention-index"), "evaluation-retention", "archive", async () => {
4488
4444
  const inventory = await retentionCandidates(args.directory);
4489
4445
  let protectedKeys = await _retentionInternals.protectedArtifacts(args.directory);
4490
4446
  const protectedRefs = inventory.candidates.filter((candidate) => protectedKeys.has(artifactKey(candidate.artifact))).map((candidate) => candidate.artifact);
@@ -4533,7 +4489,7 @@ async function archiveEvaluationArtifacts(args) {
4533
4489
  }
4534
4490
 
4535
4491
  // src/evidence/documents-retention.ts
4536
- import * as fs6 from "fs";
4492
+ import * as fs5 from "fs";
4537
4493
  import * as fsp from "fs/promises";
4538
4494
  import * as readline from "readline";
4539
4495
  var EVIDENCE_CACHE_FILE = "evidence-cache/documents.jsonl";
@@ -4543,11 +4499,11 @@ var RENAME_BACKOFF_MS = 10;
4543
4499
  var RENAME_RETRY_CODES = new Set(["EPERM", "EBUSY", "ENOTEMPTY", "EACCES"]);
4544
4500
  var _internals10 = {
4545
4501
  stat: (p) => fsp.stat(p),
4546
- createReadStream: (p, options) => fs6.createReadStream(p, options),
4547
- openSync: (p, flags) => fs6.openSync(p, flags),
4548
- writeSync: (fd, data, position) => fs6.writeSync(fd, data, position),
4549
- fsyncSync: (fd) => fs6.fsyncSync(fd),
4550
- closeSync: (fd) => fs6.closeSync(fd),
4502
+ createReadStream: (p, options) => fs5.createReadStream(p, options),
4503
+ openSync: (p, flags) => fs5.openSync(p, flags),
4504
+ writeSync: (fd, data, position) => fs5.writeSync(fd, data, position),
4505
+ fsyncSync: (fd) => fs5.fsyncSync(fd),
4506
+ closeSync: (fd) => fs5.closeSync(fd),
4551
4507
  renameWithRetry: atomicRenameWithRetry,
4552
4508
  unlink: (p) => fsp.unlink(p)
4553
4509
  };
@@ -4807,8 +4763,8 @@ function isWeakConfigContainerRoot(directory) {
4807
4763
  const resolved = realpathSync2(directory);
4808
4764
  return resolved === realpathSync2(os4.tmpdir()) || resolved === realpathSync2(os4.homedir());
4809
4765
  } catch {
4810
- const resolved = path13.resolve(directory);
4811
- return resolved === path13.resolve(os4.tmpdir()) || resolved === path13.resolve(os4.homedir());
4766
+ const resolved = path12.resolve(directory);
4767
+ return resolved === path12.resolve(os4.tmpdir()) || resolved === path12.resolve(os4.homedir());
4812
4768
  }
4813
4769
  }
4814
4770
  function hasAccessibleProjectIndicator(directory, options = {}) {
@@ -4818,7 +4774,7 @@ function hasAccessibleProjectIndicator(directory, options = {}) {
4818
4774
  continue;
4819
4775
  }
4820
4776
  try {
4821
- const indicatorStat = statSync2(path13.join(directory, indicator));
4777
+ const indicatorStat = statSync2(path12.join(directory, indicator));
4822
4778
  if (indicatorStat.isFile() || indicatorStat.isDirectory()) {
4823
4779
  return true;
4824
4780
  }
@@ -4840,14 +4796,14 @@ function validateProjectRoot(directory) {
4840
4796
  if (depth >= MAX_DEPTH)
4841
4797
  break;
4842
4798
  depth++;
4843
- const parent = path13.dirname(current);
4799
+ const parent = path12.dirname(current);
4844
4800
  if (parent === current)
4845
4801
  break;
4846
- if (path13.dirname(parent) === parent) {
4802
+ if (path12.dirname(parent) === parent) {
4847
4803
  current = parent;
4848
4804
  continue;
4849
4805
  }
4850
- const parentSwarm = path13.join(parent, ".swarm");
4806
+ const parentSwarm = path12.join(parent, ".swarm");
4851
4807
  try {
4852
4808
  if (statSync2(parentSwarm).isDirectory()) {
4853
4809
  if (hasAccessibleProjectIndicator(parent, {
@@ -4868,12 +4824,12 @@ function validateProjectRoot(directory) {
4868
4824
  async function saveEvidence(directory, taskId, evidence) {
4869
4825
  _internals11.validateProjectRoot(directory);
4870
4826
  const sanitizedTaskId = sanitizeTaskId2(taskId);
4871
- const relativePath = path13.join("evidence", sanitizedTaskId, "evidence.json");
4827
+ const relativePath = path12.join("evidence", sanitizedTaskId, "evidence.json");
4872
4828
  validateSwarmPath(directory, relativePath);
4873
4829
  _internals11.validateEvidence(evidence);
4874
4830
  return withEvidenceLock(directory, relativePath, "evidence-manager", sanitizedTaskId, async () => {
4875
4831
  const evidencePath = validateSwarmPath(directory, relativePath);
4876
- const evidenceDir = path13.dirname(evidencePath);
4832
+ const evidenceDir = path12.dirname(evidencePath);
4877
4833
  let bundle;
4878
4834
  const existingContent = await readSwarmFileAsync(directory, relativePath);
4879
4835
  if (existingContent !== null) {
@@ -4915,11 +4871,11 @@ async function saveEvidence(directory, taskId, evidence) {
4915
4871
  if (bundleJson.length > EVIDENCE_MAX_JSON_BYTES) {
4916
4872
  throw new Error(`Evidence bundle size (${bundleJson.length} bytes) exceeds maximum (${EVIDENCE_MAX_JSON_BYTES} bytes)`);
4917
4873
  }
4918
- mkdirSync5(evidenceDir, { recursive: true });
4919
- const tempPath = path13.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
4874
+ mkdirSync4(evidenceDir, { recursive: true });
4875
+ const tempPath = path12.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
4920
4876
  try {
4921
4877
  await bunWrite(tempPath, bundleJson);
4922
- await fs7.rename(tempPath, evidencePath);
4878
+ await fs6.rename(tempPath, evidencePath);
4923
4879
  } catch (error2) {
4924
4880
  try {
4925
4881
  rmSync(tempPath, { force: true });
@@ -4960,7 +4916,7 @@ function wrapFlatRetrospective(flatEntry, taskId) {
4960
4916
  }
4961
4917
  async function loadEvidence(directory, taskId, options) {
4962
4918
  const sanitizedTaskId = sanitizeTaskId2(taskId);
4963
- const relativePath = path13.join("evidence", sanitizedTaskId, "evidence.json");
4919
+ const relativePath = path12.join("evidence", sanitizedTaskId, "evidence.json");
4964
4920
  if (relativePath.length > 4096) {
4965
4921
  return { status: "not_found" };
4966
4922
  }
@@ -4984,12 +4940,12 @@ async function loadEvidence(directory, taskId, options) {
4984
4940
  }
4985
4941
  try {
4986
4942
  await withEvidenceLock(directory, relativePath, "evidence-loader", sanitizedTaskId, async () => {
4987
- const evidenceDir = path13.dirname(evidencePath);
4943
+ const evidenceDir = path12.dirname(evidencePath);
4988
4944
  const bundleJson = JSON.stringify(validated);
4989
- const tempPath = path13.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
4945
+ const tempPath = path12.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
4990
4946
  try {
4991
4947
  await bunWrite(tempPath, bundleJson);
4992
- await fs7.rename(tempPath, evidencePath);
4948
+ await fs6.rename(tempPath, evidencePath);
4993
4949
  } catch (writeError) {
4994
4950
  try {
4995
4951
  rmSync(tempPath, { force: true });
@@ -5031,7 +4987,7 @@ async function listEvidenceTaskIds(directory) {
5031
4987
  }
5032
4988
  const taskIds = [];
5033
4989
  for (const entry of entries) {
5034
- const entryPath = path13.join(evidenceBasePath, entry);
4990
+ const entryPath = path12.join(evidenceBasePath, entry);
5035
4991
  try {
5036
4992
  const stats = statSync2(entryPath);
5037
4993
  if (!stats.isDirectory()) {
@@ -5049,7 +5005,7 @@ async function listEvidenceTaskIds(directory) {
5049
5005
  }
5050
5006
  async function deleteEvidence(directory, taskId) {
5051
5007
  const sanitizedTaskId = sanitizeTaskId2(taskId);
5052
- const relativePath = path13.join("evidence", sanitizedTaskId);
5008
+ const relativePath = path12.join("evidence", sanitizedTaskId);
5053
5009
  const evidenceDir = validateSwarmPath(directory, relativePath);
5054
5010
  try {
5055
5011
  statSync2(evidenceDir);
@@ -5065,10 +5021,10 @@ async function deleteEvidence(directory, taskId) {
5065
5021
  }
5066
5022
  }
5067
5023
  async function checkRequirementCoverage(phase, directory) {
5068
- const relativePath = path13.join("evidence", `req-coverage-phase-${phase}.json`);
5069
- const absolutePath = path13.resolve(directory, ".swarm", relativePath);
5024
+ const relativePath = path12.join("evidence", `req-coverage-phase-${phase}.json`);
5025
+ const absolutePath = path12.resolve(directory, ".swarm", relativePath);
5070
5026
  try {
5071
- await fs7.access(absolutePath);
5027
+ await fs6.access(absolutePath);
5072
5028
  return { exists: true, path: absolutePath };
5073
5029
  } catch {
5074
5030
  return { exists: false, path: absolutePath };
@@ -5292,4 +5248,4 @@ function mergeDurableGateEntriesFromEvidence(taskId, entries, evidence) {
5292
5248
  return merged;
5293
5249
  }
5294
5250
 
5295
- export { getExecutor, init_executor, MAX_TRANSIENT_RETRIES, isTransientSpawnError, transientBackoff, getGitRepositoryStatus, isGitRepo, getDefaultBaseBranch, resetToRemoteBranch, resetToMainAfterMerge, initDurableStatusPath, getAllWorktreeMergeFailures, isStateUnreadable, loadEpicSessionState, isEpicModeActive, enableEpicMode, disableEpicMode, normalizePath, pathsConflict, isGlobalFile, isProtectedPath, readTaskScopes, computeSpecHash, loadPlanJsonOnly, loadPlan, savePlan, closePlanTerminalState, derivePlanMarkdown, IdentifierSchema, EvaluationTaskV1Schema, GateNameSchema, GateAuditManifestV1Schema, GateAuditResultV1Schema, canonicalJson, canonicalHash, computeTaskInputContentHash, computeTaskSetContentHash, computeManifestContentHash, resolveContainedExistingPath, admitEvaluationTask, saveTaskSetSnapshot, saveGateAuditResult, saveGateAuditManifest, readGateAuditManifest, readGateAuditResult, listGateAuditResults, isValidEvidenceType, sanitizeTaskId2 as sanitizeTaskId, validateProjectRoot, saveEvidence, loadEvidence, listEvidenceTaskIds, checkRequirementCoverage, archiveEvidence, readDurableGateEvidence, getDurableGateEvidenceStatus, getDurableGateEvidenceStatusForTask, mergeDurableGateEntriesFromEvidence };
5251
+ export { getExecutor, init_executor, MAX_TRANSIENT_RETRIES, isTransientSpawnError, transientBackoff, getGitRepositoryStatus, isGitRepo, getDefaultBaseBranch, resetToRemoteBranch, resetToMainAfterMerge, isStateUnreadable, loadEpicSessionState, isEpicModeActive, enableEpicMode, disableEpicMode, normalizePath, pathsConflict, isGlobalFile, isProtectedPath, readTaskScopes, computeSpecHash, loadPlanJsonOnly, loadPlan, savePlan, closePlanTerminalState, derivePlanMarkdown, IdentifierSchema, EvaluationTaskV1Schema, GateNameSchema, GateAuditManifestV1Schema, GateAuditResultV1Schema, canonicalJson, canonicalHash, computeTaskInputContentHash, computeTaskSetContentHash, computeManifestContentHash, resolveContainedExistingPath, admitEvaluationTask, saveTaskSetSnapshot, saveGateAuditResult, saveGateAuditManifest, readGateAuditManifest, readGateAuditResult, listGateAuditResults, isValidEvidenceType, sanitizeTaskId2 as sanitizeTaskId, validateProjectRoot, saveEvidence, loadEvidence, listEvidenceTaskIds, checkRequirementCoverage, archiveEvidence, readDurableGateEvidence, getDurableGateEvidenceStatus, getDurableGateEvidenceStatusForTask, mergeDurableGateEntriesFromEvidence };