opencode-swarm 7.167.1 → 7.168.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 (126) hide show
  1. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  2. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  3. package/dist/agents/project-context.d.ts +12 -8
  4. package/dist/cli/{coder-settlement-2ye4s5xr.js → coder-settlement-a35acvj1.js} +16 -16
  5. package/dist/cli/{config-doctor-b0k8eyd6.js → config-doctor-9csx775x.js} +3 -3
  6. package/dist/cli/{core-xgzgjk8s.js → core-agk5s7dm.js} +4 -4
  7. package/dist/cli/{curation-policy-bvxf5pxv.js → curation-policy-mgwv8h2k.js} +7 -7
  8. package/dist/cli/{curator-jpvzrxcv.js → curator-2fcagjyk.js} +45 -45
  9. package/dist/cli/{curator-drift-20m2ab5w.js → curator-drift-k0zrnm09.js} +8 -8
  10. package/dist/cli/curator-llm-factory-qaxmyy46.js +71 -0
  11. package/dist/cli/{dispatch-tmb929w8.js → dispatch-8ks9dyk5.js} +244 -70
  12. package/dist/cli/{evidence-summary-service-74az43cb.js → evidence-summary-service-4s6cje60.js} +22 -22
  13. package/dist/cli/{explorer-zvk5kbcb.js → explorer-2cv64zfj.js} +1 -1
  14. package/dist/cli/{gate-evidence-f26h2gn3.js → gate-evidence-saja4dan.js} +11 -11
  15. package/dist/cli/guardrail-explain-z41q6sf0.js +72 -0
  16. package/dist/cli/{guardrail-log-pnye3xw8.js → guardrail-log-0h24spq0.js} +9 -9
  17. package/dist/cli/{guardrail-reset-0da7q8ap.js → guardrail-reset-cwbe47k5.js} +44 -44
  18. package/dist/cli/hive-promoter-esxtcvr1.js +86 -0
  19. package/dist/cli/{index-bv8ha57q.js → index-00zx94vn.js} +6 -6
  20. package/dist/cli/{index-9e6fdz2h.js → index-0mhftbpp.js} +1 -1
  21. package/dist/cli/{index-7qefgq4j.js → index-1xnse449.js} +11 -1
  22. package/dist/cli/{index-qyr17fbz.js → index-21ree67h.js} +62 -106
  23. package/dist/cli/{index-q265ytw6.js → index-30h1pk05.js} +4 -4
  24. package/dist/cli/{index-f8xk5q5j.js → index-3dywbkyr.js} +4 -4
  25. package/dist/cli/{index-2w0beg3s.js → index-4r5pmtvk.js} +5 -5
  26. package/dist/cli/{index-69y9p6dh.js → index-54w1564x.js} +2 -2
  27. package/dist/cli/{index-251vrmge.js → index-5zqakgp4.js} +4 -4
  28. package/dist/cli/{index-bzdc4b7t.js → index-64phnth4.js} +6 -6
  29. package/dist/cli/{index-fmzz6aw7.js → index-8f0kscpg.js} +4 -4
  30. package/dist/cli/{index-t8tw1bhs.js → index-8ybjqg51.js} +2 -2
  31. package/dist/cli/{index-9ss2m4rs.js → index-9br68j86.js} +1 -1
  32. package/dist/cli/{index-4rhhvd1a.js → index-a1w58b47.js} +1 -1
  33. package/dist/cli/{index-qd619x3r.js → index-a8xbvsse.js} +2 -2
  34. package/dist/cli/{index-mgc3c483.js → index-an8b5gda.js} +10 -10
  35. package/dist/cli/{index-9wv6a3jx.js → index-bvqqwx84.js} +2 -2
  36. package/dist/cli/{index-bf6zx8cq.js → index-cyenn3pf.js} +6 -2
  37. package/dist/cli/{index-8x4zwk0t.js → index-ddr97ram.js} +47 -47
  38. package/dist/cli/{index-3nm1b3t2.js → index-dfyv3xkd.js} +8 -8
  39. package/dist/cli/{index-87agfprq.js → index-exatbqwj.js} +13 -4
  40. package/dist/cli/{index-70ha9e09.js → index-fyfbpz4f.js} +1 -1
  41. package/dist/cli/{index-5bd84nxc.js → index-gp9yzr1v.js} +1 -1
  42. package/dist/cli/{index-es13aqdb.js → index-h0e2e3h1.js} +1 -1
  43. package/dist/cli/{index-6d4dc99f.js → index-h439y187.js} +1 -1
  44. package/dist/cli/{index-9bhzbwa4.js → index-j950hqmq.js} +9 -9
  45. package/dist/cli/{index-sahf5yz3.js → index-kear8gb7.js} +11 -6
  46. package/dist/cli/{index-qww0h314.js → index-m35hybf0.js} +1 -1
  47. package/dist/cli/{index-qtd3hrk8.js → index-mr0wn36f.js} +5 -5
  48. package/dist/cli/{index-zwsbegc1.js → index-nprngf8p.js} +7 -7
  49. package/dist/cli/{index-z5gdgdkp.js → index-nsyxj57e.js} +12 -12
  50. package/dist/cli/{index-1aex5zd9.js → index-nwwk3dej.js} +2 -2
  51. package/dist/cli/{index-75f9jj3h.js → index-pyf517sz.js} +2 -2
  52. package/dist/cli/{index-m3tx1q9v.js → index-qhey6vc3.js} +1 -1
  53. package/dist/cli/{index-qd726agw.js → index-qwsh0h2g.js} +3 -3
  54. package/dist/cli/{index-n4fzmqz8.js → index-rdm3px0g.js} +4 -2
  55. package/dist/cli/index-rxcgrgkc.js +116 -0
  56. package/dist/cli/{index-54vzqy47.js → index-s0d5xter.js} +6 -6
  57. package/dist/cli/{index-emwezg3y.js → index-seetnhpx.js} +3 -3
  58. package/dist/cli/{index-0tc0pcmh.js → index-sxt7fgcw.js} +38 -2
  59. package/dist/cli/{index-m21x1bkx.js → index-v3xc4sde.js} +11 -8
  60. package/dist/cli/{index-79wnzc8q.js → index-wnzxcr0z.js} +3 -3
  61. package/dist/cli/{index-rk10x4zr.js → index-wst6n478.js} +106 -6
  62. package/dist/cli/{index-hdsg7yf6.js → index-x7k3dps5.js} +4 -3
  63. package/dist/cli/{index-32bxwzw0.js → index-yevn4jpe.js} +92908 -90093
  64. package/dist/cli/index-yv76j77m.js +2008 -0
  65. package/dist/cli/{index-f6zgz02s.js → index-z6qreakh.js} +7 -7
  66. package/dist/cli/{index-eretcr6t.js → index-ze520xw1.js} +11 -11
  67. package/dist/cli/index.js +44 -44
  68. package/dist/cli/{knowledge-escalator-p2a8xh8x.js → knowledge-escalator-b2tf3sd1.js} +17 -17
  69. package/dist/cli/{knowledge-events-jmh28m8d.js → knowledge-events-bgs2kxe0.js} +15 -15
  70. package/dist/cli/{knowledge-link-w1fwqts4.js → knowledge-link-dr3xnwyd.js} +6 -6
  71. package/dist/cli/{knowledge-store-8gmabtsn.js → knowledge-store-stbmb1b9.js} +7 -7
  72. package/dist/cli/{knowledge-validator-yk579vs4.js → knowledge-validator-zykgnsag.js} +9 -9
  73. package/dist/cli/{model-preflight-b3b5pgsc.js → model-preflight-1ycat9jz.js} +1 -1
  74. package/dist/cli/{pending-delegations-nw7ph53z.js → pending-delegations-n5qavj20.js} +14 -14
  75. package/dist/cli/{pr-subscriptions-9815fxbc.js → pr-subscriptions-gnvmyrng.js} +14 -14
  76. package/dist/cli/{pr-workflow-gate-98a7b6py.js → pr-workflow-gate-cf3ybrws.js} +44 -44
  77. package/dist/cli/{runner-nmrjv7te.js → runner-k0ycgv8x.js} +7 -7
  78. package/dist/cli/{scan-cursor-6zcs0frg.js → scan-cursor-b3mcrx23.js} +10 -10
  79. package/dist/cli/{schema-warvhy9h.js → schema-08049cjb.js} +4 -2
  80. package/dist/cli/{scope-persistence-c2ck77cv.js → scope-persistence-a493gv51.js} +20 -20
  81. package/dist/cli/{skill-generator-jamm1cna.js → skill-generator-2qqzkdpv.js} +19 -19
  82. package/dist/cli/{snapshot-coordination-init-st0xsn3f.js → snapshot-coordination-init-8yt8p7q0.js} +44 -44
  83. package/dist/cli/{sqlite-loader-xrnf6bq8.js → sqlite-loader-amp9z7ty.js} +1 -1
  84. package/dist/cli/{telemetry-ce0tx41h.js → telemetry-2wzapf11.js} +2 -2
  85. package/dist/cli/{workspace-snapshot-0kxj2grt.js → workspace-snapshot-rkgxhj9b.js} +6 -6
  86. package/dist/cli/{worktree-collision-ownership-qra7r8pw.js → worktree-collision-ownership-xttafc4h.js} +17 -17
  87. package/dist/cli/{worktree-isolation-yr9gnf64.js → worktree-isolation-e5q5rewk.js} +45 -45
  88. package/dist/commands/close/align-stage.d.ts +10 -0
  89. package/dist/commands/close/archive-stage.d.ts +34 -0
  90. package/dist/commands/close/clean-stage.d.ts +2 -0
  91. package/dist/commands/close/constants.d.ts +122 -0
  92. package/dist/commands/close/context.d.ts +129 -0
  93. package/dist/commands/close/db-helpers.d.ts +10 -0
  94. package/dist/commands/close/dry-run.d.ts +12 -0
  95. package/dist/commands/close/finalize-stage.d.ts +44 -0
  96. package/dist/commands/close/fs-helpers.d.ts +17 -0
  97. package/dist/commands/close/internals.d.ts +55 -0
  98. package/dist/commands/close/orchestrator.d.ts +32 -0
  99. package/dist/commands/close/wiring.d.ts +2 -0
  100. package/dist/commands/close.d.ts +10 -402
  101. package/dist/commands/reset.d.ts +10 -0
  102. package/dist/commands/rollback.d.ts +9 -0
  103. package/dist/config/schema.d.ts +29 -0
  104. package/dist/db/project-db.d.ts +8 -0
  105. package/dist/db/sqlite-loader.d.ts +2 -1
  106. package/dist/dispatch/spawn-circuit.d.ts +121 -0
  107. package/dist/dispatch/token-bucket.d.ts +46 -0
  108. package/dist/hooks/delegation-gate/dead-lane-reclaim.d.ts +61 -0
  109. package/dist/hooks/delegation-gate/worktree-isolation.d.ts +22 -0
  110. package/dist/hooks/issue-trace.d.ts +3 -0
  111. package/dist/hooks/utils.d.ts +1 -1
  112. package/dist/index.js +811 -726
  113. package/dist/lang/dispatch.d.ts +6 -6
  114. package/dist/plan/ledger-sqlite.d.ts +226 -0
  115. package/dist/plan/ledger.d.ts +24 -0
  116. package/dist/plan/manager.d.ts +19 -0
  117. package/dist/retention/sweep.d.ts +2 -0
  118. package/dist/services/spec-drift-recovery.d.ts +2 -1
  119. package/dist/utils/canonical-root.d.ts +19 -0
  120. package/dist/utils/ephemeral-session-teardown.d.ts +55 -2
  121. package/opencode-swarm.schema.json +41 -0
  122. package/package.json +1 -1
  123. package/dist/cli/curator-llm-factory-zeb0pe2j.js +0 -71
  124. package/dist/cli/guardrail-explain-5vhveypz.js +0 -72
  125. package/dist/cli/hive-promoter-2vj54xc4.js +0 -86
  126. package/dist/cli/index-fenasyvr.js +0 -967
@@ -3,64 +3,64 @@ import {
3
3
  getAgentSession,
4
4
  getBlockingActionCircuit,
5
5
  resetActionCircuitExternally
6
- } from "./index-32bxwzw0.js";
6
+ } from "./index-yevn4jpe.js";
7
7
  import"./index-d5qf7hvh.js";
8
- import"./index-m3tx1q9v.js";
9
- import"./index-q265ytw6.js";
10
- import"./index-bf6zx8cq.js";
11
- import"./index-qyr17fbz.js";
12
- import"./index-5bd84nxc.js";
8
+ import"./index-qhey6vc3.js";
9
+ import"./index-30h1pk05.js";
10
+ import"./index-nwwk3dej.js";
11
+ import"./index-cyenn3pf.js";
12
+ import"./index-21ree67h.js";
13
+ import"./index-gp9yzr1v.js";
13
14
  import"./index-txdagbh7.js";
15
+ import"./index-9br68j86.js";
14
16
  import"./index-cw912re7.js";
15
- import"./index-bzdc4b7t.js";
16
- import"./index-qtd3hrk8.js";
17
- import"./index-79wnzc8q.js";
18
- import"./index-70ha9e09.js";
19
- import"./index-1aex5zd9.js";
20
- import"./index-9ss2m4rs.js";
21
- import"./index-3nm1b3t2.js";
17
+ import"./index-64phnth4.js";
18
+ import"./index-mr0wn36f.js";
19
+ import"./index-wnzxcr0z.js";
20
+ import"./index-fyfbpz4f.js";
21
+ import"./index-dfyv3xkd.js";
22
22
  import"./index-zsrtt42s.js";
23
- import"./index-eretcr6t.js";
24
- import"./index-251vrmge.js";
25
- import"./index-9wv6a3jx.js";
23
+ import"./index-ze520xw1.js";
24
+ import"./index-5zqakgp4.js";
25
+ import"./index-bvqqwx84.js";
26
26
  import"./index-b43rt5ph.js";
27
27
  import"./index-q7sjgr1y.js";
28
- import"./index-bv8ha57q.js";
29
- import"./index-fmzz6aw7.js";
30
- import"./index-zwsbegc1.js";
31
- import"./index-z5gdgdkp.js";
32
- import"./index-sahf5yz3.js";
28
+ import"./index-00zx94vn.js";
29
+ import"./index-8f0kscpg.js";
30
+ import"./index-nprngf8p.js";
31
+ import"./index-nsyxj57e.js";
32
+ import"./index-kear8gb7.js";
33
33
  import"./index-p612v1mv.js";
34
- import"./index-f8xk5q5j.js";
35
- import"./index-qww0h314.js";
34
+ import"./index-3dywbkyr.js";
35
+ import"./index-m35hybf0.js";
36
36
  import"./index-rtry5xyf.js";
37
- import"./index-hdsg7yf6.js";
37
+ import"./index-x7k3dps5.js";
38
38
  import"./index-3qf1vxtb.js";
39
39
  import"./index-n832052r.js";
40
- import"./index-mgc3c483.js";
41
- import"./index-fenasyvr.js";
42
- import"./index-qd619x3r.js";
43
- import"./index-75f9jj3h.js";
44
- import"./index-6d4dc99f.js";
45
- import"./index-rk10x4zr.js";
40
+ import"./index-an8b5gda.js";
41
+ import"./index-yv76j77m.js";
42
+ import"./index-a8xbvsse.js";
43
+ import"./index-pyf517sz.js";
44
+ import"./index-h439y187.js";
45
+ import"./index-wst6n478.js";
46
+ import"./index-rdm3px0g.js";
46
47
  import"./index-ry16d01s.js";
47
- import"./index-n4fzmqz8.js";
48
- import"./index-qd726agw.js";
49
- import"./index-9bhzbwa4.js";
48
+ import"./index-qwsh0h2g.js";
49
+ import"./index-j950hqmq.js";
50
50
  import"./index-vzm6zre7.js";
51
51
  import"./index-ae75rja9.js";
52
- import"./index-t8tw1bhs.js";
53
- import"./index-2w0beg3s.js";
54
- import"./index-m21x1bkx.js";
55
- import"./index-f6zgz02s.js";
56
- import"./index-7qefgq4j.js";
57
- import"./index-ee6ydtfe.js";
52
+ import"./index-8ybjqg51.js";
53
+ import"./index-4r5pmtvk.js";
58
54
  import"./index-7g4c7s5r.js";
59
- import"./index-emwezg3y.js";
60
- import"./index-9e6fdz2h.js";
61
- import"./index-4rhhvd1a.js";
62
- import"./index-87agfprq.js";
63
- import"./index-0tc0pcmh.js";
55
+ import"./index-v3xc4sde.js";
56
+ import"./index-z6qreakh.js";
57
+ import"./index-1xnse449.js";
58
+ import"./index-ee6ydtfe.js";
59
+ import"./index-seetnhpx.js";
60
+ import"./index-0mhftbpp.js";
61
+ import"./index-a1w58b47.js";
62
+ import"./index-exatbqwj.js";
63
+ import"./index-sxt7fgcw.js";
64
64
  import"./index-bk5tah7q.js";
65
65
  import"./index-bpmtbmy9.js";
66
66
  import"./index-zpsr8rpc.js";
@@ -0,0 +1,86 @@
1
+ // @bun
2
+ import {
3
+ _internals3 as _internals,
4
+ checkHivePromotions,
5
+ countDistinctProjects,
6
+ createHivePromoterHook,
7
+ isHiveEligible,
8
+ promoteFromSwarm,
9
+ promoteToHive
10
+ } from "./index-yevn4jpe.js";
11
+ import"./index-d5qf7hvh.js";
12
+ import"./index-qhey6vc3.js";
13
+ import"./index-30h1pk05.js";
14
+ import"./index-nwwk3dej.js";
15
+ import"./index-cyenn3pf.js";
16
+ import"./index-21ree67h.js";
17
+ import"./index-gp9yzr1v.js";
18
+ import"./index-txdagbh7.js";
19
+ import"./index-9br68j86.js";
20
+ import"./index-cw912re7.js";
21
+ import"./index-64phnth4.js";
22
+ import"./index-mr0wn36f.js";
23
+ import"./index-wnzxcr0z.js";
24
+ import"./index-fyfbpz4f.js";
25
+ import"./index-dfyv3xkd.js";
26
+ import"./index-zsrtt42s.js";
27
+ import"./index-ze520xw1.js";
28
+ import"./index-5zqakgp4.js";
29
+ import"./index-bvqqwx84.js";
30
+ import"./index-b43rt5ph.js";
31
+ import"./index-q7sjgr1y.js";
32
+ import"./index-00zx94vn.js";
33
+ import"./index-8f0kscpg.js";
34
+ import"./index-nprngf8p.js";
35
+ import"./index-nsyxj57e.js";
36
+ import"./index-kear8gb7.js";
37
+ import"./index-p612v1mv.js";
38
+ import"./index-3dywbkyr.js";
39
+ import"./index-m35hybf0.js";
40
+ import"./index-rtry5xyf.js";
41
+ import"./index-x7k3dps5.js";
42
+ import"./index-3qf1vxtb.js";
43
+ import"./index-n832052r.js";
44
+ import"./index-an8b5gda.js";
45
+ import"./index-yv76j77m.js";
46
+ import"./index-a8xbvsse.js";
47
+ import"./index-pyf517sz.js";
48
+ import"./index-h439y187.js";
49
+ import"./index-wst6n478.js";
50
+ import"./index-rdm3px0g.js";
51
+ import"./index-ry16d01s.js";
52
+ import"./index-qwsh0h2g.js";
53
+ import {
54
+ resolveHiveKnowledgePath
55
+ } from "./index-j950hqmq.js";
56
+ import"./index-vzm6zre7.js";
57
+ import"./index-ae75rja9.js";
58
+ import"./index-8ybjqg51.js";
59
+ import"./index-4r5pmtvk.js";
60
+ import"./index-7g4c7s5r.js";
61
+ import"./index-v3xc4sde.js";
62
+ import"./index-z6qreakh.js";
63
+ import"./index-1xnse449.js";
64
+ import"./index-ee6ydtfe.js";
65
+ import"./index-seetnhpx.js";
66
+ import"./index-0mhftbpp.js";
67
+ import"./index-a1w58b47.js";
68
+ import"./index-exatbqwj.js";
69
+ import"./index-sxt7fgcw.js";
70
+ import"./index-bk5tah7q.js";
71
+ import"./index-bpmtbmy9.js";
72
+ import"./index-zpsr8rpc.js";
73
+ import"./index-q1r1cfww.js";
74
+ import"./index-yzjaj53h.js";
75
+ import"./index-zgwm4ryv.js";
76
+ import"./index-a76rekgs.js";
77
+ export {
78
+ resolveHiveKnowledgePath,
79
+ promoteToHive,
80
+ promoteFromSwarm,
81
+ isHiveEligible,
82
+ createHivePromoterHook,
83
+ countDistinctProjects,
84
+ checkHivePromotions,
85
+ _internals
86
+ };
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  autoCommitDirty,
4
4
  cleanUntrackedFiles
5
- } from "./index-fmzz6aw7.js";
5
+ } from "./index-8f0kscpg.js";
6
6
  import {
7
7
  validateSwarmPath
8
- } from "./index-sahf5yz3.js";
8
+ } from "./index-kear8gb7.js";
9
9
  import {
10
10
  bunSpawn,
11
11
  classifySpawnFailure
@@ -15,18 +15,18 @@ import {
15
15
  atomicWriteFile,
16
16
  taskEvidencePath,
17
17
  withTaskEvidenceLock
18
- } from "./index-2w0beg3s.js";
18
+ } from "./index-4r5pmtvk.js";
19
19
  import {
20
20
  telemetry
21
- } from "./index-f6zgz02s.js";
21
+ } from "./index-z6qreakh.js";
22
22
  import {
23
23
  init_git_executable,
24
24
  resolveGitExecutable
25
- } from "./index-9e6fdz2h.js";
25
+ } from "./index-0mhftbpp.js";
26
26
  import {
27
27
  advisoryWarn,
28
28
  init_warning_buffer
29
- } from "./index-4rhhvd1a.js";
29
+ } from "./index-a1w58b47.js";
30
30
  import {
31
31
  exports_external,
32
32
  init_zod
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  advisoryWarn,
4
4
  init_warning_buffer
5
- } from "./index-4rhhvd1a.js";
5
+ } from "./index-a1w58b47.js";
6
6
  import {
7
7
  __esm
8
8
  } from "./index-a76rekgs.js";
@@ -18,6 +18,9 @@ function normalizeIdentityPath(resolved) {
18
18
  function lexicalRootAliasKey(directory) {
19
19
  return normalizeIdentityPath(path.resolve(directory));
20
20
  }
21
+ function canonicalRootKeyLexical(directory) {
22
+ return lexicalRootAliasKey(directory);
23
+ }
21
24
  function resolveCanonicalRootKey(directory) {
22
25
  let resolved = path.resolve(directory);
23
26
  try {
@@ -29,6 +32,13 @@ function resolveCanonicalRootKey(directory) {
29
32
  }
30
33
  return normalizeIdentityPath(resolved);
31
34
  }
35
+ async function canonicalRootKeyFreshAsync(directory) {
36
+ let resolved = path.resolve(directory);
37
+ try {
38
+ resolved = await fsSync.promises.realpath(resolved);
39
+ } catch {}
40
+ return normalizeIdentityPath(resolved);
41
+ }
32
42
  function canonicalRootKey(directory) {
33
43
  const memoized = canonicalRootMemo.get(directory);
34
44
  if (memoized !== undefined) {
@@ -68,4 +78,4 @@ function sessionKeySuffix(sessionId) {
68
78
  return `${SESSION_KEY_SEPARATOR}${sessionId}`;
69
79
  }
70
80
 
71
- export { _internals, lexicalRootAliasKey, canonicalRootKey, canonicalRootKeyFresh, sameProjectRoot, compositeSessionKey, sessionKeySuffix };
81
+ export { _internals, lexicalRootAliasKey, canonicalRootKeyLexical, canonicalRootKeyFreshAsync, canonicalRootKey, canonicalRootKeyFresh, sameProjectRoot, compositeSessionKey, sessionKeySuffix };
@@ -3,13 +3,13 @@ import {
3
3
  EvaluationRunV1Schema,
4
4
  GateAuditResultV1Schema,
5
5
  getProtectedEvaluationRunIds
6
- } from "./index-5bd84nxc.js";
6
+ } from "./index-gp9yzr1v.js";
7
+ import {
8
+ readEffectiveSpecSync
9
+ } from "./index-9br68j86.js";
7
10
  import {
8
11
  validateWorkspaceRoot
9
12
  } from "./index-cw912re7.js";
10
- import {
11
- readEffectiveSpecSync
12
- } from "./index-9ss2m4rs.js";
13
13
  import {
14
14
  getWorktreeMergeFailure
15
15
  } from "./index-zsrtt42s.js";
@@ -23,13 +23,13 @@ import {
23
23
  readTaskEvidence,
24
24
  readTaskEvidenceRaw,
25
25
  sanitizeTaskId
26
- } from "./index-bv8ha57q.js";
26
+ } from "./index-00zx94vn.js";
27
27
  import {
28
28
  estimateCharsForTokens,
29
29
  estimateTokens,
30
30
  readSwarmFileAsync,
31
31
  validateSwarmPath
32
- } from "./index-sahf5yz3.js";
32
+ } from "./index-kear8gb7.js";
33
33
  import {
34
34
  bunHash,
35
35
  bunWrite,
@@ -52,15 +52,16 @@ import {
52
52
  normalizeExecutionProfileForHash,
53
53
  readLedgerEvents,
54
54
  readLedgerEventsWithIntegrity,
55
+ replacePlanLedgerWithRoot,
55
56
  replaceTruncatedLedgerWithRecoveryRoot,
56
57
  replayFromLedger,
57
58
  replayFromLedgerWithStatus,
58
59
  takeSnapshotEvent,
59
60
  takeSnapshotWithRetry
60
- } from "./index-fenasyvr.js";
61
+ } from "./index-yv76j77m.js";
61
62
  import {
62
63
  appendCoreEventSync
63
- } from "./index-qd619x3r.js";
64
+ } from "./index-a8xbvsse.js";
64
65
  import {
65
66
  derivePlanId,
66
67
  derivePlanIdentityHash,
@@ -68,38 +69,38 @@ import {
68
69
  importCoordinationOnce,
69
70
  listCoordinationStates,
70
71
  transitionCoordinationState
71
- } from "./index-6d4dc99f.js";
72
+ } from "./index-h439y187.js";
72
73
  import {
73
74
  DURABILITY_CLASSES,
74
75
  getProjectDb,
75
76
  projectDbExists,
76
77
  withDurabilityClass
77
- } from "./index-rk10x4zr.js";
78
+ } from "./index-wst6n478.js";
78
79
  import {
79
80
  assertProjectRoot,
80
81
  tryAcquireLock,
81
82
  withEvidenceLock
82
- } from "./index-2w0beg3s.js";
83
+ } from "./index-4r5pmtvk.js";
83
84
  import {
84
85
  atomicWriteSwarmFileSync,
85
86
  invalidateCachedArtifact,
86
87
  readCachedParsedFile
87
- } from "./index-m21x1bkx.js";
88
+ } from "./index-v3xc4sde.js";
88
89
  import {
89
90
  emit
90
- } from "./index-f6zgz02s.js";
91
+ } from "./index-z6qreakh.js";
91
92
  import {
92
93
  canonicalRootKeyFresh
93
- } from "./index-7qefgq4j.js";
94
+ } from "./index-1xnse449.js";
94
95
  import {
95
96
  PlanSchema
96
- } from "./index-emwezg3y.js";
97
+ } from "./index-seetnhpx.js";
97
98
  import {
98
99
  GIT_BINARY_ENV_VAR,
99
100
  describeGitResolution,
100
101
  init_git_executable,
101
102
  resolveGitExecutable
102
- } from "./index-9e6fdz2h.js";
103
+ } from "./index-0mhftbpp.js";
103
104
  import {
104
105
  ZodError,
105
106
  init_zod
@@ -119,12 +120,9 @@ import {
119
120
  // src/plan/manager.ts
120
121
  import {
121
122
  closeSync,
122
- copyFileSync,
123
- existsSync as existsSync3,
124
123
  fsyncSync,
125
124
  mkdirSync as mkdirSync2,
126
125
  openSync,
127
- readdirSync,
128
126
  renameSync as renameSync2,
129
127
  unlinkSync,
130
128
  writeFileSync
@@ -1880,6 +1878,8 @@ var PLAN_JSON_CACHE_NAMESPACE = "plan-json:validated:v1";
1880
1878
  var _internals5 = {
1881
1879
  loadPlan,
1882
1880
  loadPlanJsonOnly,
1881
+ readPlanJsonUtf8,
1882
+ readPlanFileUtf8,
1883
1883
  regeneratePlanMarkdown,
1884
1884
  isGitRepo,
1885
1885
  isEpicModeActiveForProject,
@@ -2038,14 +2038,20 @@ async function surfaceLedgerStaleIfPersisted(directory, plan) {
2038
2038
  }
2039
2039
  async function parsePlanJsonCached(directory) {
2040
2040
  const planJsonPath = path4.resolve(directory, ".swarm", "plan.json");
2041
- return readCachedParsedFile(planJsonPath, PLAN_JSON_CACHE_NAMESPACE, () => readSwarmFileAsync(directory, "plan.json"), (planJsonContent) => {
2042
- if (planJsonContent.includes("\x00") || planJsonContent.includes("\uFFFD")) {
2043
- throw new Error("Plan rejected: .swarm/plan.json contains null bytes or invalid encoding");
2041
+ return readCachedParsedFile(planJsonPath, PLAN_JSON_CACHE_NAMESPACE, () => _internals5.readPlanJsonUtf8(directory), (planJsonContent) => {
2042
+ if (planJsonContent.includes("\x00")) {
2043
+ throw new Error("Plan rejected: .swarm/plan.json contains null bytes");
2044
2044
  }
2045
2045
  const parsed = JSON.parse(planJsonContent);
2046
2046
  return PlanSchema.parse(parsed);
2047
2047
  });
2048
2048
  }
2049
+ async function readPlanJsonUtf8(directory) {
2050
+ return readSwarmFileAsync(directory, "plan.json", undefined, (filePath) => _internals5.readPlanFileUtf8(filePath), false);
2051
+ }
2052
+ async function readPlanFileUtf8(filePath) {
2053
+ return new TextDecoder("utf-8", { fatal: true }).decode(await fsPromises.readFile(filePath));
2054
+ }
2049
2055
  function computePlanContentHash(plan) {
2050
2056
  const content = {
2051
2057
  schema_version: plan.schema_version,
@@ -2117,10 +2123,15 @@ ${markdown}`;
2117
2123
  invalidateCachedArtifact(mdPath);
2118
2124
  }
2119
2125
  async function loadPlan(directory, cache) {
2120
- const planJsonContent = await readSwarmFileAsync(directory, "plan.json", cache);
2126
+ let planJsonContent = null;
2127
+ try {
2128
+ planJsonContent = await _internals5.readPlanJsonUtf8(directory);
2129
+ } catch (error2) {
2130
+ warn(`Plan rejected: .swarm/plan.json could not be decoded as valid UTF-8: ${error2 instanceof Error ? error2.message : String(error2)}`);
2131
+ }
2121
2132
  if (planJsonContent !== null) {
2122
- if (planJsonContent.includes("\x00") || planJsonContent.includes("\uFFFD")) {
2123
- warn("Plan rejected: .swarm/plan.json contains null bytes or invalid encoding");
2133
+ if (planJsonContent.includes("\x00")) {
2134
+ warn("Plan rejected: .swarm/plan.json contains null bytes");
2124
2135
  } else {
2125
2136
  try {
2126
2137
  const validated = await parsePlanJsonCached(directory);
@@ -2286,12 +2297,6 @@ async function loadPlan(directory, cache) {
2286
2297
  }
2287
2298
  }
2288
2299
  }
2289
- const planMdContent = await readSwarmFileAsync(directory, "plan.md", cache);
2290
- if (planMdContent !== null) {
2291
- const migrated = migrateLegacyPlan(planMdContent);
2292
- await savePlan(directory, migrated);
2293
- return migrated;
2294
- }
2295
2300
  if (await ledgerExists(directory)) {
2296
2301
  const resolvedDir = canonicalRootKeyFresh(directory);
2297
2302
  const existingMutex = recoveryMutexes.get(resolvedDir);
@@ -2354,6 +2359,12 @@ async function loadPlan(directory, cache) {
2354
2359
  recoveryMutexes.delete(resolvedDir);
2355
2360
  }
2356
2361
  }
2362
+ const planMdContent = await readSwarmFileAsync(directory, "plan.md", cache);
2363
+ if (planMdContent !== null) {
2364
+ const migrated = migrateLegacyPlan(planMdContent);
2365
+ await savePlan(directory, migrated);
2366
+ return migrated;
2367
+ }
2357
2368
  return null;
2358
2369
  }
2359
2370
  async function savePlanWithAutoAcknowledgedRemovals(directory, plan, source, reason, options) {
@@ -2378,6 +2389,20 @@ async function savePlanWithAutoAcknowledgedRemovals(directory, plan, source, rea
2378
2389
  });
2379
2390
  return { removedCount: removedIds.length };
2380
2391
  }
2392
+ async function withPlanLifecycleLock(directory, taskId, fn) {
2393
+ assertProjectRoot(directory);
2394
+ const lockResult = await tryAcquireLock(directory, "plan.json", "plan-lifecycle", taskId);
2395
+ if (!lockResult.acquired) {
2396
+ throw new PlanConcurrentModificationError(`Plan lifecycle blocked: plan.json is locked by ${lockResult.existing?.agent ?? "another agent"} (task: ${lockResult.existing?.taskId ?? "unknown"})`);
2397
+ }
2398
+ try {
2399
+ return await fn();
2400
+ } finally {
2401
+ if (lockResult.lock._release) {
2402
+ await lockResult.lock._release().catch(() => {});
2403
+ }
2404
+ }
2405
+ }
2381
2406
  async function savePlan(directory, plan, options) {
2382
2407
  if (directory === null || directory === undefined || typeof directory !== "string" || directory.trim().length === 0) {
2383
2408
  throw new Error(`Invalid directory: directory must be a non-empty string`);
@@ -2445,78 +2470,9 @@ async function savePlan(directory, plan, options) {
2445
2470
  } else {
2446
2471
  const existingEvents = await readLedgerEvents(directory);
2447
2472
  if (existingEvents.length > 0 && existingEvents[0].plan_id !== planId) {
2448
- const swarmDir2 = path4.resolve(directory, ".swarm");
2449
- const oldLedgerPath = path4.join(swarmDir2, "plan-ledger.jsonl");
2450
- const oldLedgerBackupPath = path4.join(swarmDir2, `plan-ledger.backup-${Date.now()}-${Math.floor(Math.random() * 1e9)}.jsonl`);
2451
- let backupExists = false;
2452
- if (existsSync3(oldLedgerPath)) {
2453
- try {
2454
- options?.preCommitCheck?.();
2455
- renameSync2(oldLedgerPath, oldLedgerBackupPath);
2456
- backupExists = true;
2457
- } catch (renameErr) {
2458
- 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.`);
2459
- }
2460
- }
2461
- let initSucceeded = false;
2462
- if (backupExists) {
2463
- try {
2464
- options?.preCommitCheck?.();
2465
- await initLedger(directory, planId, planHashForInit, validated);
2466
- initSucceeded = true;
2467
- } catch (initErr) {
2468
- const errorMessage2 = String(initErr);
2469
- if (errorMessage2.includes("already initialized")) {
2470
- try {
2471
- if (existsSync3(oldLedgerBackupPath))
2472
- unlinkSync(oldLedgerBackupPath);
2473
- } catch {}
2474
- } else {
2475
- if (existsSync3(oldLedgerBackupPath)) {
2476
- try {
2477
- renameSync2(oldLedgerBackupPath, oldLedgerPath);
2478
- } catch {
2479
- copyFileSync(oldLedgerBackupPath, oldLedgerPath);
2480
- try {
2481
- unlinkSync(oldLedgerBackupPath);
2482
- } catch {}
2483
- }
2484
- }
2485
- throw initErr;
2486
- }
2487
- }
2488
- }
2489
- if (initSucceeded && backupExists) {
2490
- const archivePath = path4.join(swarmDir2, `plan-ledger.archived-${Date.now()}-${Math.floor(Math.random() * 1e9)}.jsonl`);
2491
- try {
2492
- renameSync2(oldLedgerBackupPath, archivePath);
2493
- warn(`[savePlan] Ledger identity mismatch (was "${existingEvents[0].plan_id}", now "${planId}") \u2014 archived old ledger to ${archivePath} and reinitializing.`);
2494
- } catch (renameErr) {
2495
- warn(`[savePlan] Could not archive old ledger (rename failed: ${renameErr instanceof Error ? renameErr.message : String(renameErr)}). Old ledger may still exist at ${oldLedgerBackupPath}.`);
2496
- try {
2497
- if (existsSync3(oldLedgerBackupPath))
2498
- unlinkSync(oldLedgerBackupPath);
2499
- } catch {}
2500
- }
2501
- } else if (!initSucceeded && backupExists) {
2502
- try {
2503
- if (existsSync3(oldLedgerBackupPath))
2504
- unlinkSync(oldLedgerBackupPath);
2505
- } catch {}
2506
- }
2507
- const MAX_ARCHIVED_SIBLINGS = 5;
2508
- try {
2509
- const allFiles = readdirSync(swarmDir2);
2510
- const archivedSiblings = allFiles.filter((f) => f.startsWith("plan-ledger.archived-") && f.endsWith(".jsonl")).sort();
2511
- if (archivedSiblings.length > MAX_ARCHIVED_SIBLINGS) {
2512
- const toRemove = archivedSiblings.slice(0, archivedSiblings.length - MAX_ARCHIVED_SIBLINGS);
2513
- for (const file of toRemove) {
2514
- try {
2515
- unlinkSync(path4.join(swarmDir2, file));
2516
- } catch {}
2517
- }
2518
- }
2519
- } catch {}
2473
+ options?.preCommitCheck?.();
2474
+ await replacePlanLedgerWithRoot(directory, validated, "savePlan_identity_migration");
2475
+ warn(`[savePlan] Ledger identity mismatch (was "${existingEvents[0].plan_id}", now "${planId}") \u2014 archived the prior exact history and committed a new root.`);
2520
2476
  }
2521
2477
  }
2522
2478
  if (options?.staleProjectionReconcile) {
@@ -3339,7 +3295,7 @@ function migrateLegacyPlan(planContent, swarmId) {
3339
3295
  init_zod();
3340
3296
  import {
3341
3297
  mkdirSync as mkdirSync3,
3342
- readdirSync as readdirSync2,
3298
+ readdirSync,
3343
3299
  realpathSync,
3344
3300
  renameSync as renameSync3,
3345
3301
  rmSync,
@@ -3936,7 +3892,7 @@ async function listEvidenceTaskIds(directory) {
3936
3892
  }
3937
3893
  let entries;
3938
3894
  try {
3939
- entries = readdirSync2(evidenceBasePath);
3895
+ entries = readdirSync(evidenceBasePath);
3940
3896
  } catch {
3941
3897
  return [];
3942
3898
  }
@@ -4210,4 +4166,4 @@ function mergeDurableGateEntriesFromEvidence(taskId, entries, evidence) {
4210
4166
  return merged;
4211
4167
  }
4212
4168
 
4213
- export { normalizePath, buildTaskCompletionDescriptor, ensureTaskCheckpointReceipt, updateTaskCheckpointReceipt, MAX_TRANSIENT_RETRIES, isTransientSpawnError, transientBackoff, readLaneEnvFileFromDiskSync, getGitRepositoryStatus, isGitRepo, getDefaultBaseBranch, detectDefaultRemoteBranch, resetToRemoteBranch, resetToMainAfterMerge, isStateUnreadable, loadEpicSessionState, isEpicModeActive, enableEpicMode, disableEpicMode, pathsConflict, isGlobalFile, isProtectedPath, readTaskScopes, loadPlanJsonOnly, loadPlan, savePlan, closePlanTerminalState, updateTaskStatus, derivePlanMarkdown, isValidEvidenceType, isSecretscanEvidence, sanitizeTaskId2 as sanitizeTaskId, validateProjectRoot, saveEvidence, loadEvidence, listEvidenceTaskIds, checkRequirementCoverage, archiveEvidence, readDurableGateEvidence, getDurableGateEvidenceStatus, getDurableGateEvidenceStatusForTask, mergeDurableGateEntriesFromEvidence };
4169
+ export { normalizePath, buildTaskCompletionDescriptor, ensureTaskCheckpointReceipt, updateTaskCheckpointReceipt, MAX_TRANSIENT_RETRIES, isTransientSpawnError, transientBackoff, readLaneEnvFileFromDiskSync, getGitRepositoryStatus, isGitRepo, getDefaultBaseBranch, detectDefaultRemoteBranch, resetToRemoteBranch, resetToMainAfterMerge, isStateUnreadable, loadEpicSessionState, isEpicModeActive, enableEpicMode, disableEpicMode, pathsConflict, isGlobalFile, isProtectedPath, readTaskScopes, loadPlanJsonOnly, loadPlan, withPlanLifecycleLock, savePlan, closePlanTerminalState, updateTaskStatus, derivePlanMarkdown, isValidEvidenceType, isSecretscanEvidence, sanitizeTaskId2 as sanitizeTaskId, validateProjectRoot, saveEvidence, loadEvidence, listEvidenceTaskIds, checkRequirementCoverage, archiveEvidence, readDurableGateEvidence, getDurableGateEvidenceStatus, getDurableGateEvidenceStatusForTask, mergeDurableGateEntriesFromEvidence };
@@ -1,17 +1,17 @@
1
1
  // @bun
2
2
  import {
3
3
  observeStoreHealth
4
- } from "./index-qd726agw.js";
4
+ } from "./index-qwsh0h2g.js";
5
5
  import {
6
6
  telemetry
7
- } from "./index-f6zgz02s.js";
7
+ } from "./index-z6qreakh.js";
8
8
  import {
9
9
  init_schema,
10
10
  stripKnownSwarmPrefix
11
- } from "./index-87agfprq.js";
11
+ } from "./index-exatbqwj.js";
12
12
  import {
13
13
  init_constants
14
- } from "./index-0tc0pcmh.js";
14
+ } from "./index-sxt7fgcw.js";
15
15
  import {
16
16
  getPathFlavor,
17
17
  init_path_identity,
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  authorizeCuration
4
- } from "./index-qww0h314.js";
4
+ } from "./index-m35hybf0.js";
5
5
  import {
6
6
  findNearDuplicate,
7
7
  inferTags,
@@ -9,13 +9,13 @@ import {
9
9
  resolveSwarmKnowledgePath,
10
10
  resolveSwarmRejectedPath,
11
11
  transactKnowledge
12
- } from "./index-9bhzbwa4.js";
12
+ } from "./index-j950hqmq.js";
13
13
  import {
14
14
  resolveKnowledgeStoreDir
15
- } from "./index-t8tw1bhs.js";
15
+ } from "./index-8ybjqg51.js";
16
16
  import {
17
17
  atomicWriteFile
18
- } from "./index-2w0beg3s.js";
18
+ } from "./index-4r5pmtvk.js";
19
19
  import {
20
20
  require_proper_lockfile
21
21
  } from "./index-7g4c7s5r.js";
@@ -1,13 +1,13 @@
1
1
  // @bun
2
+ import {
3
+ require_proper_lockfile
4
+ } from "./index-7g4c7s5r.js";
2
5
  import {
3
6
  atomicWriteFileAnyRoot
4
- } from "./index-m21x1bkx.js";
7
+ } from "./index-v3xc4sde.js";
5
8
  import {
6
9
  emit
7
- } from "./index-f6zgz02s.js";
8
- import {
9
- require_proper_lockfile
10
- } from "./index-7g4c7s5r.js";
10
+ } from "./index-z6qreakh.js";
11
11
  import {
12
12
  init_logger,
13
13
  warn
@@ -14,14 +14,14 @@ import {
14
14
  detectWindowsWrites,
15
15
  getSharedClassifierGuardrailBlock,
16
16
  resolveWriteTargets
17
- } from "./index-32bxwzw0.js";
17
+ } from "./index-yevn4jpe.js";
18
18
  import {
19
19
  checkFileAuthority,
20
20
  classifyFile,
21
21
  isInDeclaredScope,
22
22
  redactPath,
23
23
  redactShellCommand
24
- } from "./index-q265ytw6.js";
24
+ } from "./index-30h1pk05.js";
25
25
 
26
26
  // src/services/guardrail-explain-service.ts
27
27
  import path from "path";