@cortexkit/opencode-magic-context 0.49.81 → 0.49.82

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 (156) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +4 -4
  3. package/dist/{conflict-warning-hook-8s8r0c0v.js → conflict-warning-hook-a0wrnzch.js} +2 -2
  4. package/dist/{context-359s1ncq.js → context-00f1hdz2.js} +251 -29
  5. package/dist/{embedding-backfill-0tvprmrn.js → embedding-backfill-k994xdas.js} +4 -4
  6. package/dist/features/magic-context/memory/identity-merge-command.d.ts +4 -0
  7. package/dist/features/magic-context/memory/identity-merge-command.d.ts.map +1 -0
  8. package/dist/features/magic-context/memory/project-binding-notice.d.ts +5 -0
  9. package/dist/features/magic-context/memory/project-binding-notice.d.ts.map +1 -0
  10. package/dist/features/magic-context/memory/project-identity.d.ts +1 -0
  11. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  12. package/dist/features/magic-context/storage-clone.d.ts +17 -0
  13. package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
  14. package/dist/features/magic-context/store-generation-rebase.d.ts +13 -0
  15. package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
  16. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +1 -7
  17. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  18. package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
  19. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  20. package/dist/hooks/magic-context/stored-compartment-gaps.d.ts +16 -0
  21. package/dist/hooks/magic-context/stored-compartment-gaps.d.ts.map +1 -0
  22. package/dist/hooks/magic-context/transform.d.ts +1 -0
  23. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  24. package/dist/{index-m4q6ptgz.js → index-2xhzmwf6.js} +4 -4
  25. package/dist/{index-jhhkb4jv.js → index-2ygw6q5s.js} +1 -1
  26. package/dist/{index-v0epndb8.js → index-93rezfvc.js} +22 -2
  27. package/dist/{index-1rx9bfrk.js → index-b2787fk6.js} +111 -40
  28. package/dist/{index-tebcx987.js → index-bd34njzg.js} +1 -1
  29. package/dist/{index-zpd4pxnp.js → index-dg5jvh9r.js} +6 -6
  30. package/dist/{index-6athgjba.js → index-e21n48yd.js} +34 -2
  31. package/dist/{index-726b5jh5.js → index-eptthgkw.js} +5 -5
  32. package/dist/{index-9554nr2q.js → index-fgy6hnr3.js} +6 -1
  33. package/dist/{index-tzy5h4x6.js → index-fpqdbb67.js} +1 -1
  34. package/dist/{v2/server-x8a7jmkh.js → index-fzgyvsb1.js} +15 -4
  35. package/dist/{index-1sq1krqw.js → index-g6hfh4h4.js} +4 -4
  36. package/dist/{index-wwzamy3j.js → index-hz1xdb15.js} +3 -3
  37. package/dist/{index-6sckwxjj.js → index-jvr9ba9y.js} +151 -37
  38. package/dist/{index-m6rkq3t4.js → index-rnyaa7cj.js} +1 -1
  39. package/dist/{index-yfn52pb6.js → index-shpyv8gq.js} +2 -2
  40. package/dist/{index-7jefmy0g.js → index-stx8zd81.js} +2 -2
  41. package/dist/{index-jg7sbt3v.js → index-vpw46557.js} +1 -1
  42. package/dist/{index-xx05vta0.js → index-w2wpx7t5.js} +1 -1
  43. package/dist/{index-177yv84k.js → index-w8dcjt7f.js} +1 -1
  44. package/dist/{index-ma258g0g.js → index-wxxcfpxh.js} +5 -5
  45. package/dist/{index-xsdaz3mq.js → index-x8qgqnym.js} +30 -11
  46. package/dist/{index-aawwdt26.js → index-zvane1rq.js} +2 -2
  47. package/dist/index.js +31 -31
  48. package/dist/migration-worker.js +3 -3
  49. package/dist/plugin/rpc-handlers.d.ts +2 -0
  50. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  51. package/dist/{project-embedding-registry-sw4z2ptg.js → project-embedding-registry-y3z36mjy.js} +3 -3
  52. package/dist/raw-ordinal-warmup-worker.js +2 -2
  53. package/dist/{recomp-orchestrator-ar3xw3f4.js → recomp-orchestrator-fjdp3t1d.js} +14 -14
  54. package/dist/{render-bjxgkrk6.js → render-c9fjwrad.js} +6 -6
  55. package/dist/{rpc-notifications-3hed126v.js → rpc-notifications-t9q0ynq7.js} +3 -1
  56. package/dist/{search-z56487n8.js → search-1jejx5cx.js} +9 -9
  57. package/dist/{search-archive-p3jhx9wc.js → search-archive-s2jas2jb.js} +2 -2
  58. package/dist/{send-session-notification-ykvt5k2s.js → send-session-notification-7x518gew.js} +1 -1
  59. package/dist/shared/prompt-surface-runtime.d.ts +1 -1
  60. package/dist/shared/rpc-notifications.d.ts +8 -3
  61. package/dist/shared/rpc-notifications.d.ts.map +1 -1
  62. package/dist/shared/rpc-types.d.ts +4 -0
  63. package/dist/shared/rpc-types.d.ts.map +1 -1
  64. package/dist/shared/status-summary.d.ts +2 -0
  65. package/dist/shared/status-summary.d.ts.map +1 -1
  66. package/dist/shared/status-view-check.d.ts.map +1 -1
  67. package/dist/shared/status-view.d.ts +1 -0
  68. package/dist/shared/status-view.d.ts.map +1 -1
  69. package/dist/shared/user-facing-codes.d.ts +5 -0
  70. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  71. package/dist/{store-8trkpmtx.js → store-ggrq9e14.js} +6 -2
  72. package/dist/{store-reader-3eh1s1m8.js → store-reader-tr64nxyy.js} +1 -1
  73. package/dist/tools/ctx-memory/constants.d.ts +1 -1
  74. package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
  75. package/dist/tools/light-descriptions.d.ts +1 -1
  76. package/dist/tools/light-descriptions.d.ts.map +1 -1
  77. package/dist/tools/parameter-descriptions.d.ts +6 -6
  78. package/dist/tools/parameter-descriptions.d.ts.map +1 -1
  79. package/dist/{transform-postprocess-phase-6kyqctnq.js → transform-postprocess-phase-p2egg02g.js} +15 -15
  80. package/dist/v2/auto-search-worker.js +3 -3
  81. package/dist/v2/chunk-embedding-write-worker.js +4 -4
  82. package/dist/v2/{context-dpe94zcx.js → context-gwkgh0wd.js} +368 -43
  83. package/dist/v2/{embedding-backfill-qnaswpmb.js → embedding-backfill-hjvjxp7d.js} +4 -4
  84. package/dist/v2/fork-inheritance.d.ts +25 -17
  85. package/dist/v2/fork-inheritance.d.ts.map +1 -1
  86. package/dist/v2/hidden-child-native.d.ts +6 -6
  87. package/dist/v2/hidden-child-native.d.ts.map +1 -1
  88. package/dist/v2/hidden-child-record.d.ts +21 -3
  89. package/dist/v2/hidden-child-record.d.ts.map +1 -1
  90. package/dist/v2/hidden-child-sweep.d.ts +1 -1
  91. package/dist/v2/hidden-child-sweep.d.ts.map +1 -1
  92. package/dist/v2/hidden-completion.d.ts +1 -0
  93. package/dist/v2/hidden-completion.d.ts.map +1 -1
  94. package/dist/v2/hidden-run-holder.d.ts +16 -0
  95. package/dist/v2/hidden-run-holder.d.ts.map +1 -0
  96. package/dist/v2/hooks/context.d.ts.map +1 -1
  97. package/dist/v2/hooks/dream-timer.d.ts +5 -7
  98. package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
  99. package/dist/v2/hooks/fork-history-status.d.ts +10 -0
  100. package/dist/v2/hooks/fork-history-status.d.ts.map +1 -0
  101. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  102. package/dist/v2/hooks/store.d.ts +4 -0
  103. package/dist/v2/hooks/store.d.ts.map +1 -1
  104. package/dist/v2/hooks/types.d.ts +5 -26
  105. package/dist/v2/hooks/types.d.ts.map +1 -1
  106. package/dist/v2/migration-worker.js +3 -3
  107. package/dist/v2/{project-embedding-registry-52f2jept.js → project-embedding-registry-mzsvyads.js} +3 -3
  108. package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
  109. package/dist/v2/{recomp-orchestrator-7t6fkpbb.js → recomp-orchestrator-jn39mxh0.js} +13 -13
  110. package/dist/v2/{render-hwqk0d8t.js → render-q2aj9bgy.js} +6 -6
  111. package/dist/v2/{rpc-notifications-3hed126v.js → rpc-notifications-t9q0ynq7.js} +3 -1
  112. package/dist/v2/{search-eftsvbg7.js → search-9xn6ds9x.js} +8 -8
  113. package/dist/v2/{search-archive-mdxzvgpm.js → search-archive-fj59gjv1.js} +2 -2
  114. package/dist/v2/{send-session-notification-8g4r97bp.js → send-session-notification-p52rhjzy.js} +1 -1
  115. package/dist/v2/{server-ma9jwnas.js → server-1cn3kryt.js} +4 -4
  116. package/dist/v2/{server-34pvhvxt.js → server-1efjj215.js} +22 -2
  117. package/dist/v2/{server-jn4pktdk.js → server-2ktxmtbd.js} +1 -1
  118. package/dist/v2/{server-zw1e3wq5.js → server-2w1rdttn.js} +1 -1
  119. package/dist/v2/{server-jtq03rkb.js → server-4z964n1c.js} +1 -1
  120. package/dist/v2/{server-pxdpwycq.js → server-53n8hv5q.js} +6 -6
  121. package/dist/v2/{server-rbtx6q5v.js → server-569he5mh.js} +1 -1
  122. package/dist/v2/{server-rthnpmbp.js → server-5yfq912a.js} +34 -2
  123. package/dist/v2/{server-mhrgymcs.js → server-68q80y27.js} +2 -2
  124. package/dist/v2/{server-afsz3cmx.js → server-bt546axy.js} +1 -1
  125. package/dist/v2/{server-dhdn8mwq.js → server-c8mqs0v5.js} +30 -11
  126. package/dist/{index-x8a7jmkh.js → v2/server-fzgyvsb1.js} +15 -4
  127. package/dist/v2/{server-76v5y7zm.js → server-g1a0nhtk.js} +2 -2
  128. package/dist/v2/{server-25qtxt4d.js → server-gx1s06dx.js} +6 -1
  129. package/dist/v2/{server-x8ksqcw7.js → server-pejjj0nv.js} +1 -1
  130. package/dist/v2/{server-a1zp7exh.js → server-vt6nj2hn.js} +106 -35
  131. package/dist/v2/{server-qjff96a6.js → server-wdq85mxj.js} +4 -4
  132. package/dist/v2/server.js +3 -3
  133. package/dist/v2/{store-m3zny7q2.js → store-qdgzd38f.js} +6 -2
  134. package/dist/v2/{store-reader-yaxtdy6f.js → store-reader-83tka051.js} +1 -1
  135. package/dist/v2/store-reader.d.ts +15 -8
  136. package/dist/v2/store-reader.d.ts.map +1 -1
  137. package/dist/v2/tui/index.d.ts +1 -1
  138. package/dist/v2/tui/index.d.ts.map +1 -1
  139. package/dist/v2/{v2-archive-reader-p89x05hj.js → v2-archive-reader-9z8z97db.js} +1 -1
  140. package/dist/v2/{wrapup-orchestrator-c0bwb0wa.js → wrapup-orchestrator-vd5zfp3v.js} +13 -13
  141. package/dist/{v2-archive-reader-vzmzb245.js → v2-archive-reader-r0xpxsb1.js} +1 -1
  142. package/dist/{wrapup-orchestrator-548q5y55.js → wrapup-orchestrator-k29zqfp9.js} +15 -15
  143. package/package.json +1 -1
  144. package/src/agents/smart-notes-dreamer-gate.golden.json +169 -169
  145. package/src/shared/prompt-surface-a1-golden.md +8 -7
  146. package/src/shared/rpc-notifications.test.ts +29 -0
  147. package/src/shared/rpc-notifications.ts +24 -5
  148. package/src/shared/rpc-types.ts +4 -0
  149. package/src/shared/status-summary.ts +9 -1
  150. package/src/shared/status-view-check.ts +2 -0
  151. package/src/shared/status-view.test.ts +9 -0
  152. package/src/shared/status-view.ts +4 -0
  153. package/src/shared/user-facing-codes.ts +5 -0
  154. package/src/tui/slots/sidebar-content.tsx +11 -5
  155. package/src/tui-compiled/slots/sidebar-content.tsx +191 -176
  156. package/src/v2/tui/index.ts +7 -2
@@ -114,6 +114,9 @@ import {
114
114
  DREAMER_CLASSIFIER_AGENT,
115
115
  DREAMER_DOCS_AGENT,
116
116
  DREAMER_REVIEWER_AGENT,
117
+ supportsQuietHiddenChildren,
118
+ matchesHiddenRunLocation,
119
+ hiddenRunPlacement,
117
120
  HIDDEN_HISTORIAN_AGENT,
118
121
  HIDDEN_DREAMER_AGENT,
119
122
  HIDDEN_CURATE_AGENT,
@@ -158,6 +161,7 @@ import {
158
161
  runTokenLog,
159
162
  formatRunTokenLog,
160
163
  createChildSessionWithFence,
164
+ validateStoredCompartments,
161
165
  buildMagicContextSection,
162
166
  getMuralIdentity,
163
167
  getMural,
@@ -217,11 +221,12 @@ import {
217
221
  hasRunnableCompartmentWindow,
218
222
  recordHighPressureNoEligibleHead,
219
223
  noteTransformPassForExactOrdinalReads,
224
+ nonNarrativeStoredGapRanges,
220
225
  getActiveCompartmentRun,
221
226
  startCompartmentAgent,
222
227
  setRecompStarting2,
223
228
  setRecompTerminal2
224
- } from "./server-a1zp7exh.js";
229
+ } from "./server-vt6nj2hn.js";
225
230
  import {
226
231
  resolveHistorianModel2
227
232
  } from "./server-5kym00ag.js";
@@ -239,6 +244,7 @@ import {
239
244
  setHomeProjectPermission,
240
245
  shouldSkipHomeProjectMemory,
241
246
  ProjectIdentityError,
247
+ directoryFallback,
242
248
  takeDubiousOwnershipProjectIdentityWarning,
243
249
  isUserHomeDirectory,
244
250
  resolveProjectIdentity,
@@ -250,7 +256,7 @@ import {
250
256
  storedPathBelongsToIdentity,
251
257
  beginBootQuietPeriod,
252
258
  scheduleAfterBootQuiet
253
- } from "./server-afsz3cmx.js";
259
+ } from "./server-bt546axy.js";
254
260
  import"./server-v0p37hm2.js";
255
261
  import {
256
262
  inRootAsyncContext2,
@@ -650,7 +656,7 @@ import {
650
656
  resolveMemoriesByIdsForSearch2,
651
657
  unifiedSearch2,
652
658
  formatSearchResults2
653
- } from "./server-pxdpwycq.js";
659
+ } from "./server-53n8hv5q.js";
654
660
  import {
655
661
  embedPauseBySession,
656
662
  embedRunStateBySession,
@@ -798,7 +804,7 @@ import {
798
804
  saveSourceContent,
799
805
  replaceSourceContent,
800
806
  getSourceContents
801
- } from "./server-dhdn8mwq.js";
807
+ } from "./server-c8mqs0v5.js";
802
808
  import {
803
809
  startBootDeadline,
804
810
  getUnconfirmedMigrationHolders,
@@ -814,7 +820,7 @@ import {
814
820
  openDatabaseAsync,
815
821
  isDatabasePersisted,
816
822
  getDatabasePersistenceError
817
- } from "./server-76v5y7zm.js";
823
+ } from "./server-g1a0nhtk.js";
818
824
  import {
819
825
  V2_MEMORY_CATEGORIES,
820
826
  CATEGORY_PRIORITY
@@ -827,13 +833,13 @@ import {
827
833
  resolveStoredPathWorkspaceIdentity,
828
834
  storedPathBelongsToWorkspace,
829
835
  computeWorkspaceEpochFingerprint
830
- } from "./server-jn4pktdk.js";
836
+ } from "./server-2ktxmtbd.js";
831
837
  import {
832
838
  gaDatabasePath2,
833
839
  RAW_MESSAGE_TYPES2,
834
840
  V2StoreReaderPool2,
835
841
  V2StoreReader2
836
- } from "./server-rthnpmbp.js";
842
+ } from "./server-5yfq912a.js";
837
843
  import {
838
844
  configureContextDatabasePragmas2
839
845
  } from "./server-fb3zxn06.js";
@@ -862,7 +868,7 @@ import {
862
868
  createPrimer,
863
869
  updatePrimerSupport,
864
870
  updatePrimerAnswer
865
- } from "./server-rbtx6q5v.js";
871
+ } from "./server-569he5mh.js";
866
872
  import {
867
873
  deriveTriggerBudget2,
868
874
  deriveHistorianChunkTokens2,
@@ -895,7 +901,7 @@ import {
895
901
  embedSessionCompartmentChunks2,
896
902
  getEmbeddingCoverageStatus2,
897
903
  getAutoEmbeddingSessionCoverage2
898
- } from "./server-mhrgymcs.js";
904
+ } from "./server-68q80y27.js";
899
905
  import {
900
906
  GIT_SWEEP_LEASE_RENEWAL_MS,
901
907
  acquireGitSweepLease,
@@ -905,7 +911,7 @@ import {
905
911
  releaseGitSweepLease,
906
912
  recordSessionProjectIdentity,
907
913
  hasRecordedSessionProjectIdentity
908
- } from "./server-jtq03rkb.js";
914
+ } from "./server-4z964n1c.js";
909
915
  import {
910
916
  saveEmbeddingIfHashMatches,
911
917
  invalidateProject2,
@@ -935,8 +941,8 @@ import {
935
941
  readGitFileChangeTimesSince,
936
942
  verificationFileExists,
937
943
  normalizeVerificationFiles
938
- } from "./server-25qtxt4d.js";
939
- import"./server-x8ksqcw7.js";
944
+ } from "./server-gx1s06dx.js";
945
+ import"./server-pejjj0nv.js";
940
946
  import {
941
947
  computeCueContentHash,
942
948
  hasMuralCueColumns,
@@ -961,20 +967,22 @@ import {
961
967
  supersededMemory2,
962
968
  mergeMemoryStats2,
963
969
  archiveMemory2,
970
+ getMemoryCount2,
964
971
  getMemoryCountsByStatus2
965
972
  } from "./server-jjvbk92s.js";
966
973
  import {
967
974
  registerNotificationSink2,
975
+ pushLiveNotification2,
968
976
  pushNotification2,
969
977
  acknowledgeNotifications2,
970
978
  drainNotifications2,
971
979
  isTuiConnected2
972
- } from "./server-x8a7jmkh.js";
980
+ } from "./server-fzgyvsb1.js";
973
981
  import"./server-npdey91q.js";
974
982
  import {
975
983
  flushIgnoredMessages2,
976
984
  sendStatusNotification2
977
- } from "./server-qjff96a6.js";
985
+ } from "./server-wdq85mxj.js";
978
986
  import {
979
987
  rememberHostMedia,
980
988
  hostMediaAsset,
@@ -990,13 +998,15 @@ import {
990
998
  HOST_RESTORE_MEDIA,
991
999
  restoreRow,
992
1000
  rawMessagePage2,
1001
+ readV2MessageRange2,
1002
+ iterateV2MessageRange2,
993
1003
  servedBoundaryRow2,
994
1004
  resolveV2BoundaryUserMessage2,
995
1005
  readAllV2RawMessagesForConversion2,
996
1006
  readV2RawMessagePagesForConversion2,
997
1007
  createV2RawMessageReader2,
998
1008
  createV2RawMessageProvider2
999
- } from "./server-34pvhvxt.js";
1009
+ } from "./server-1efjj215.js";
1000
1010
  import {
1001
1011
  resolvePromptContext2
1002
1012
  } from "./server-fmsr7v69.js";
@@ -1008,10 +1018,10 @@ import {
1008
1018
  import"./server-52x68mj4.js";
1009
1019
  import {
1010
1020
  readV2ArchiveOffThread2
1011
- } from "./server-ma9jwnas.js";
1021
+ } from "./server-1cn3kryt.js";
1012
1022
  import {
1013
1023
  renderSearchArchiveOffThread2
1014
- } from "./server-zw1e3wq5.js";
1024
+ } from "./server-2w1rdttn.js";
1015
1025
  import {
1016
1026
  markHostInstructionRow,
1017
1027
  hostInstructionRow,
@@ -13471,6 +13481,79 @@ function createSystemPromptHashHandler(deps) {
13471
13481
  };
13472
13482
  }
13473
13483
 
13484
+ // src/features/magic-context/memory/identity-merge-command.ts
13485
+ var IDENTITY_MERGE_COMMAND = "npx @cortexkit/magic-context@latest doctor merge-identities";
13486
+ var IDENTITY_MERGE_PREVIEW_HINT = "It shows what would move. Add --apply to move them.";
13487
+ function shellArg(value, platform) {
13488
+ if (/^[\w.:/-]+$/.test(value))
13489
+ return value;
13490
+ return platform === "win32" ? `"${value}"` : `'${value.replaceAll("'", "'\\''")}'`;
13491
+ }
13492
+ function identityMergeCommand(from, to, platform = process.platform) {
13493
+ return `${IDENTITY_MERGE_COMMAND} --from ${shellArg(from, platform)} --to ${to ? shellArg(to, platform) : '"DESTINATION_IDENTITY"'}`;
13494
+ }
13495
+
13496
+ // src/features/magic-context/memory/project-binding-notice.ts
13497
+ var observedBindings = new WeakMap;
13498
+ function bindingLog(harness, directory, old, identity, memories) {
13499
+ return `project binding changed harness=${harness} cwd=${directory || "unknown"} old=${old ?? "none"} new=${identity} memories=${memories}`;
13500
+ }
13501
+ function observeSessionProjectBinding(db, sessionId, identity, directory, notify) {
13502
+ const change = recordSessionProjectIdentity(db, sessionId, identity);
13503
+ const harness = getHarness2();
13504
+ let observations = observedBindings.get(db);
13505
+ if (!observations) {
13506
+ observations = new BoundedSessionMap(1000);
13507
+ observedBindings.set(db, observations);
13508
+ }
13509
+ const key = `${harness}\x00${sessionId}`;
13510
+ const last = observations.get(key);
13511
+ const noticed = last?.noticed ?? new Set;
13512
+ const observation = {
13513
+ directory,
13514
+ noticed,
13515
+ warning: change ? undefined : last?.warning
13516
+ };
13517
+ observations.set(key, observation);
13518
+ const old = change?.previousProjectPath;
13519
+ if (!change || !old && harness !== "pi" && harness !== "omp")
13520
+ return;
13521
+ const memories = old ? getMemoryCount2(db, old) : 0;
13522
+ const binding = bindingLog(harness, directory, old, identity, memories);
13523
+ if (!old || !memories) {
13524
+ sessionLog2(sessionId, binding);
13525
+ return;
13526
+ }
13527
+ const oldDirectory = [last?.directory, directory].find((path) => path && directoryFallback(path) === old);
13528
+ const location = oldDirectory ? `the old folder (${oldDirectory})` : `the old project (${old})`;
13529
+ let guidance;
13530
+ if (old.startsWith("dir:") && /^(dir|git):/.test(identity)) {
13531
+ guidance = `Review the merge first:
13532
+ ${identityMergeCommand(oldDirectory ?? old, identity)}
13533
+ ${IDENTITY_MERGE_PREVIEW_HINT}`;
13534
+ } else if (old.startsWith("git:") && identity.startsWith("dir:")) {
13535
+ guidance = "A repository's memories cannot be merged into a folder project.";
13536
+ } else {
13537
+ guidance = "Run `npx @cortexkit/magic-context@latest doctor` to see how these memories can be merged.";
13538
+ }
13539
+ const count = `${memories} ${memories === 1 ? "memory" : "memories"}`;
13540
+ observation.warning = `${count} stayed under this session's previous project. Nothing was moved.
13541
+ ${guidance}`;
13542
+ if (noticed.has(old)) {
13543
+ sessionLog2(sessionId, binding);
13544
+ return;
13545
+ }
13546
+ noticed.add(old);
13547
+ const notice = `This session changed projects. ${count} stayed with ${location}; nothing moved. ${guidance}`;
13548
+ sessionLog2(sessionId, `${binding} notice=${JSON.stringify(notice)}`);
13549
+ try {
13550
+ notify?.(notice);
13551
+ } catch {}
13552
+ }
13553
+ function getProjectBindingWarning(db, sessionId) {
13554
+ return observedBindings.get(db)?.peek(`${getHarness2()}\x00${sessionId}`)?.warning;
13555
+ }
13556
+
13474
13557
  // src/hooks/magic-context/compaction-off-transition.ts
13475
13558
  import { existsSync } from "node:fs";
13476
13559
  var loggedUnverifiedMarkerCleanupRetry = false;
@@ -18779,7 +18862,11 @@ function createRustModeTransform(deps, options) {
18779
18862
  const sessionProjectIdentity = (options.sessionProjectIdentityResolverForTests ?? resolveProjectIdentityForSession)(directory, deps.allowHomeProject);
18780
18863
  if (sessionProjectIdentity) {
18781
18864
  if (state.recordedSessionProjectIdentity !== sessionProjectIdentity) {
18782
- recordSessionProjectIdentity(deps.db, sessionId, sessionProjectIdentity);
18865
+ observeSessionProjectBinding(deps.db, sessionId, sessionProjectIdentity, directory, (notice) => {
18866
+ withoutSqliteTransformPass2(() => sendStatusNotification2(deps.client, sessionId, `## Project memory warning
18867
+
18868
+ ${notice}`, {}));
18869
+ });
18783
18870
  }
18784
18871
  state.recordedSessionProjectIdentity = sessionProjectIdentity;
18785
18872
  state.recordedSessionDirectory = directory;
@@ -21578,7 +21665,15 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
21578
21665
  const authorityProjectPath = (deps.memoryConfig?.enabled ? projectIdentity : undefined) ?? deps.projectPath ?? sessionProjectIdentity;
21579
21666
  if (authorityProjectPath) {}
21580
21667
  if (sessionIdentityForBinding && sessionDirectoryResolvedFromHost && recordedSessionProjectIdentity.get(sessionId) !== sessionIdentityForBinding) {
21581
- recordSessionProjectIdentity(db, sessionId, sessionIdentityForBinding);
21668
+ observeSessionProjectBinding(db, sessionId, sessionIdentityForBinding, sessionDirectory, (notice) => {
21669
+ if (deps.hostProjectBindingNotice)
21670
+ deps.hostProjectBindingNotice(sessionId, notice);
21671
+ else {
21672
+ withoutSqliteTransformPass2(() => sendStatusNotification2(deps.client, sessionId, `## Project memory warning
21673
+
21674
+ ${notice}`, notificationParams));
21675
+ }
21676
+ });
21582
21677
  recordedSessionProjectIdentity.set(sessionId, sessionIdentityForBinding);
21583
21678
  }
21584
21679
  const taggerFloor = compactionOff ? 0 : deriveTaggerLoadFloor(messages, sessionId, db);
@@ -25544,6 +25639,7 @@ function buildSidebarSnapshot(db, sessionId, directory, liveSessionState, inject
25544
25639
  readySmartNoteCount,
25545
25640
  cacheTtl,
25546
25641
  lastTransformError: meta?.last_transform_error ? String(meta.last_transform_error) : null,
25642
+ projectBindingWarning: getProjectBindingWarning(db, sessionId),
25547
25643
  lastDreamerRunAt,
25548
25644
  projectIdentity,
25549
25645
  dreamerBacklog,
@@ -26048,6 +26144,15 @@ function registerRpcHandlers(rpcServer, args) {
26048
26144
  const rawConfig = config;
26049
26145
  const getNotificationParams = (sessionId) => getLiveNotificationParams(sessionId, liveSessionState.liveModelBySession, liveSessionState.variantBySession, liveSessionState.agentBySession, currentPluginConfigReader(directory)?.poll().effective.toast_duration_ms ?? config.toast_duration_ms);
26050
26146
  const injectionBudgetTokens = config.memory?.injection_budget_tokens;
26147
+ const showForkHistoryGap = (db, sessionId) => {
26148
+ if (!compactionEnabled || config.transform_mode === "rust")
26149
+ return false;
26150
+ try {
26151
+ return args.readForkHistoryGap?.(db, sessionId) === true;
26152
+ } catch {
26153
+ return false;
26154
+ }
26155
+ };
26051
26156
  if (isDebugRpcEnabled(config)) {
26052
26157
  const readMemory = () => buildDebugMemoryUsage(args.getDebugMemoryHolders?.());
26053
26158
  rpcServer.handle("debug.memoryUsage", async () => ({ ...readMemory() }));
@@ -26068,7 +26173,10 @@ function registerRpcHandlers(rpcServer, args) {
26068
26173
  error: "Rust module status unavailable; canonical session state was not read"
26069
26174
  };
26070
26175
  }
26071
- return buildSidebarSnapshotRpcResponse(db, sessionId, dir, liveSessionState, injectionBudgetTokens, rawConfig, moduleStatus, compactionEnabled);
26176
+ const snapshot = buildSidebarSnapshotRpcResponse(db, sessionId, dir, liveSessionState, injectionBudgetTokens, rawConfig, moduleStatus, compactionEnabled);
26177
+ if (!snapshot.error && snapshot.disabled !== true && showForkHistoryGap(db, sessionId))
26178
+ snapshot.forkHistoryGap = true;
26179
+ return snapshot;
26072
26180
  });
26073
26181
  rpcServer.handle("session-owner", async (params) => {
26074
26182
  const sessionId = String(params.sessionId ?? "");
@@ -26102,6 +26210,8 @@ function registerRpcHandlers(rpcServer, args) {
26102
26210
  };
26103
26211
  }
26104
26212
  const detail = buildStatusDetail(db, sessionId, dir, modelKey, rawConfig, liveSessionState, injectionBudgetTokens, moduleStatus, compactionEnabled);
26213
+ if (showForkHistoryGap(db, sessionId))
26214
+ detail.forkHistoryGap = true;
26105
26215
  if (args.hiddenCompletionExecutor?.capabilities.tools === false) {
26106
26216
  detail.dreamerUnsupportedTasks = toolLoopDreamTasks();
26107
26217
  }
@@ -26197,8 +26307,8 @@ function registerRpcHandlers(rpcServer, args) {
26197
26307
  const db = readDatabase();
26198
26308
  if (!db)
26199
26309
  return { ok: false, error: "db unavailable" };
26200
- const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-7t6fkpbb.js"));
26201
- const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-8g4r97bp.js"));
26310
+ const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-jn39mxh0.js"));
26311
+ const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-p52rhjzy.js"));
26202
26312
  log2(`[rpc] recomp requested for session ${sessionId}`);
26203
26313
  if (!args.client && !args.hiddenCompletionExecutor) {
26204
26314
  return {
@@ -26282,7 +26392,7 @@ function registerRpcHandlers(rpcServer, args) {
26282
26392
  const db = readDatabase();
26283
26393
  if (!db)
26284
26394
  return { ok: false, error: "db unavailable" };
26285
- const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-c0bwb0wa.js"));
26395
+ const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-vd5zfp3v.js"));
26286
26396
  const model = await args.readSelectedSessionModel?.(sessionId) ?? liveSessionState.liveModelBySession.get(sessionId);
26287
26397
  const window = resolveOpenCodeWrapupWindow(db, sessionId, model);
26288
26398
  if (!window)
@@ -27041,9 +27151,9 @@ var FULL_PARAMETER_DESCRIPTIONS = {
27041
27151
  },
27042
27152
  ctx_memory: {
27043
27153
  action: "write | update | archive | merge | get",
27044
- content: "The memory text — one standalone fact (write, update, merge). Archive and get take an empty string.",
27045
- category: "Kind of fact: the new fact's kind for write; on update/merge, the memory's current category to keep it. Archive and get ignore it.",
27046
- ids: "Memory ids from <project-memory>: one for update, one or more for archive, two or more for merge, 1–20 for get. Write takes an empty list.",
27154
+ content: "Send on every call — the memory text for write, update and merge; pass an empty string for archive and get.",
27155
+ category: "Send on every call — the fact's kind for write; on update/merge, the memory's current category to keep it; archive and get ignore it, so pass any valid category.",
27156
+ ids: "Send on every call — one id for update, one or more for archive, two or more distinct ids of memories in the same category for merge, 1–20 for get; write takes an empty list.",
27047
27157
  reason: "Why it is being archived (optional)."
27048
27158
  },
27049
27159
  ctx_search: {
@@ -27076,9 +27186,9 @@ var LIGHT_PARAMETER_DESCRIPTIONS = {
27076
27186
  },
27077
27187
  ctx_memory: {
27078
27188
  action: "write | update | archive | merge | get",
27079
- content: "One standalone fact (write, update, merge). Archive and get: empty string.",
27080
- category: "Kind of fact (write; on update/merge pass the current category to keep it). Archive and get ignore it.",
27081
- ids: "Ids from <project-memory>: one for update, 1+ for archive, 2+ for merge, 1–20 for get. Write: empty list.",
27189
+ content: "Send on every call: the fact (write, update, merge); empty string for archive/get.",
27190
+ category: "Send on every call: kind for write; current category for update/merge; any category for archive/get (ignored).",
27191
+ ids: "Send on every call: one id for update, 1+ for archive, 2+ distinct same-category ids for merge, 1–20 for get; write: empty list.",
27082
27192
  reason: "Why it is archived (optional)."
27083
27193
  },
27084
27194
  ctx_search: {
@@ -30048,7 +30158,123 @@ function splitMessageScopedId(id) {
30048
30158
  return { messageId: id, suffix: "" };
30049
30159
  return { messageId: id.slice(0, -match[1].length), suffix: match[1] };
30050
30160
  }
30051
- function forkCloneFilter(idMap, copiedToolCallIds) {
30161
+ function selectForkCompartments(source, map, proof) {
30162
+ const rows = new Map;
30163
+ const forkId = (id) => map.parentToFork.get(id) ?? "";
30164
+ const ordinal = (id) => map.forkOrdinals.get(forkId(id));
30165
+ let matchingPrefix;
30166
+ const provePrefix = () => {
30167
+ const matching = proof.matchingBodies();
30168
+ let length = 0;
30169
+ for (const [position, id] of map.parentOrdinals) {
30170
+ if (ordinal(id) !== position || matching.get(id) !== forkId(id))
30171
+ break;
30172
+ length = position;
30173
+ }
30174
+ return length;
30175
+ };
30176
+ let stopped = false;
30177
+ let lastEnd = 0;
30178
+ let acceptedGaps;
30179
+ const conversionGaps = [];
30180
+ const inheritedGaps = [];
30181
+ for (const [i, row] of source.entries()) {
30182
+ const { sequence, startMessage, endMessage, startMessageId, endMessageId } = row;
30183
+ const start = ordinal(startMessageId);
30184
+ const end = ordinal(endMessageId);
30185
+ let reason;
30186
+ if (stopped) {
30187
+ reason = "after first skipped compartment";
30188
+ } else {
30189
+ const startSeq = start === undefined ? proof.sequenceForId(startMessageId) : undefined;
30190
+ const endSeq = end === undefined ? proof.sequenceForId(endMessageId) : undefined;
30191
+ const previous = source[i - 1];
30192
+ const next = source[i + 1];
30193
+ if ((startSeq ?? -1) > map.throughSeq || (endSeq ?? -1) > map.throughSeq) {
30194
+ reason = "outside the fork boundary";
30195
+ } else if (startSeq !== undefined || endSeq !== undefined) {
30196
+ reason = "a live endpoint was not copied";
30197
+ } else if (row.rebaseStatus === "unresolved") {
30198
+ reason = "parent coordinates are unresolved";
30199
+ } else if (!Number.isSafeInteger(startMessage) || !Number.isSafeInteger(endMessage) || startMessage < 1 || endMessage < startMessage) {
30200
+ reason = "invalid message range";
30201
+ } else if (startMessage <= lastEnd) {
30202
+ reason = "range overlaps the inherited prefix";
30203
+ } else if (startMessage > lastEnd + 1 && validateStoredCompartments(lastEnd > 0 ? [{ startMessage: 1, endMessage: lastEnd }, row] : [row], acceptedGaps ??= proof.acceptedGaps(source, (gap) => conversionGaps.push(gap))) !== null) {
30204
+ reason = "gap before range";
30205
+ } else if (start !== undefined && start !== startMessage || end !== undefined && end !== endMessage) {
30206
+ reason = "live endpoint conflicts with the stored position";
30207
+ } else if (start === undefined && previous && ordinal(previous.endMessageId) !== lastEnd || end === undefined && (!next || next.startMessage !== endMessage + 1 || ordinal(next.startMessageId) !== endMessage + 1)) {
30208
+ reason = "live neighboring anchors do not prove the stored range";
30209
+ } else if ((end === undefined ? endMessage + 1 : endMessage) > (matchingPrefix ??= provePrefix())) {
30210
+ reason = "parent and fork raw prefixes do not match in order and body";
30211
+ } else {
30212
+ rows.set(sequence, {
30213
+ sequence,
30214
+ startMessage,
30215
+ endMessage,
30216
+ startMessageId: forkId(map.parentOrdinals.get(startMessage) ?? ""),
30217
+ endMessageId: forkId(map.parentOrdinals.get(endMessage) ?? "")
30218
+ });
30219
+ const conversionGap = conversionGaps.find(({ start, end }) => start === lastEnd + 1 && end === startMessage - 1);
30220
+ if (conversionGap)
30221
+ inheritedGaps.push(conversionGap);
30222
+ lastEnd = endMessage;
30223
+ continue;
30224
+ }
30225
+ stopped = true;
30226
+ }
30227
+ sessionLog2(proof.sessionId, `v2 fork skipped compartment ${sequence} (${startMessage}-${endMessage}): ${reason}`);
30228
+ }
30229
+ const keepRaw = new Set;
30230
+ if (stopped) {
30231
+ const count = map.parentOrdinals.size;
30232
+ const changes = new Int32Array(count + 2);
30233
+ const markCovered = (from, to) => {
30234
+ const start = Math.max(1, from);
30235
+ const end = Math.min(count, to);
30236
+ if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start > end)
30237
+ return;
30238
+ changes[start] = (changes[start] ?? 0) + 1;
30239
+ changes[end + 1] = (changes[end + 1] ?? 0) - 1;
30240
+ };
30241
+ const parentPositions = new Map([...map.parentOrdinals].map(([position, id]) => [id, position]));
30242
+ const liveOrdinal = (id) => {
30243
+ const position = parentPositions.get(id);
30244
+ if (position !== undefined)
30245
+ return position;
30246
+ return (proof.sequenceForId(id) ?? -1) > map.throughSeq ? count + 1 : undefined;
30247
+ };
30248
+ const live = source.map((row) => ({
30249
+ start: liveOrdinal(row.startMessageId),
30250
+ end: liveOrdinal(row.endMessageId)
30251
+ }));
30252
+ for (const [index, row] of source.entries()) {
30253
+ if (rows.has(row.sequence))
30254
+ continue;
30255
+ markCovered(row.startMessage, row.endMessage);
30256
+ const { start, end } = live[index] ?? {};
30257
+ if (start === undefined && end === undefined)
30258
+ continue;
30259
+ const previousEnd = live[index - 1]?.end;
30260
+ const nextStart = live[index + 1]?.start;
30261
+ const from = start ?? (previousEnd !== undefined ? previousEnd + 1 : index === 0 ? 1 : undefined);
30262
+ const to = end ?? (nextStart !== undefined ? nextStart - 1 : undefined);
30263
+ if (from !== undefined && to !== undefined)
30264
+ markCovered(from, to);
30265
+ else
30266
+ markCovered(Math.min(row.startMessage, from ?? row.startMessage), Math.max(row.endMessage, to ?? row.endMessage));
30267
+ }
30268
+ let covering = 0;
30269
+ for (const [position, id] of map.parentOrdinals) {
30270
+ covering += changes[position] ?? 0;
30271
+ if (covering > 0)
30272
+ keepRaw.add(id);
30273
+ }
30274
+ }
30275
+ return { rows, keepRaw, inheritedGaps };
30276
+ }
30277
+ function forkCloneFilter(idMap, copiedToolCallIds, proof, toolOwners) {
30052
30278
  const mapMessageScoped = (id) => {
30053
30279
  const direct = idMap.parentToFork.get(id);
30054
30280
  if (direct)
@@ -30059,14 +30285,28 @@ function forkCloneFilter(idMap, copiedToolCallIds) {
30059
30285
  const mapped = idMap.parentToFork.get(messageId);
30060
30286
  return mapped ? `${mapped}${suffix}` : undefined;
30061
30287
  };
30288
+ let keepRaw;
30289
+ let inheritedGaps = [];
30290
+ const includeMessageId = (messageId) => mapMessageScoped(messageId) !== undefined || copiedToolCallIds.has(messageId);
30062
30291
  return {
30292
+ selectCompartments: proof && ((source) => {
30293
+ const plan = selectForkCompartments(source, idMap, proof);
30294
+ keepRaw = plan.keepRaw;
30295
+ inheritedGaps = plan.inheritedGaps;
30296
+ return plan.rows;
30297
+ }),
30298
+ inheritedCoordinateGaps: proof && (() => inheritedGaps),
30063
30299
  resolveBoundaryOrdinal: (messageId) => {
30064
30300
  const forkId = idMap.parentToFork.get(messageId);
30065
30301
  return forkId ? idMap.forkOrdinals.get(forkId) : undefined;
30066
30302
  },
30067
- includeMessageId: (messageId) => mapMessageScoped(messageId) !== undefined || copiedToolCallIds.has(messageId),
30303
+ includeMessageId,
30304
+ includeReplayMessageId: (messageId) => includeMessageId(messageId) && !keepRaw?.has(splitMessageScopedId(messageId).messageId) && !toolOwners?.get(messageId)?.some((owner) => keepRaw?.has(owner)),
30068
30305
  mapMessageId: (messageId) => mapMessageScoped(messageId) ?? messageId,
30069
30306
  includeTag: (tag) => {
30307
+ const owner = tag.type === "tool" ? tag.toolOwnerMessageId : splitMessageScopedId(tag.messageId).messageId;
30308
+ if (owner && keepRaw?.has(owner))
30309
+ return false;
30070
30310
  if (tag.type === "tool") {
30071
30311
  return tag.toolOwnerMessageId !== null && idMap.parentToFork.has(tag.toolOwnerMessageId);
30072
30312
  }
@@ -30110,7 +30350,20 @@ function seedV2ForkFromParent(args) {
30110
30350
  return { kind: "parent-missing", parentSessionID, reason: "no copied rows pair up" };
30111
30351
  const toolTags = db.prepare("SELECT message_id, tool_owner_message_id FROM tags WHERE session_id = ? AND type = 'tool'").all(parentSessionID);
30112
30352
  const copiedToolCallIds = new Set(toolTags.filter((row) => row.tool_owner_message_id !== null && idMap.parentToFork.has(row.tool_owner_message_id)).map((row) => row.message_id));
30113
- const result = copySessionStateForClone(db, parentSessionID, sessionId, forkCloneFilter(idMap, copiedToolCallIds));
30353
+ const toolOwners = new Map;
30354
+ for (const row of toolTags) {
30355
+ if (!row.tool_owner_message_id)
30356
+ continue;
30357
+ const owners = toolOwners.get(row.message_id) ?? [];
30358
+ owners.push(row.tool_owner_message_id);
30359
+ toolOwners.set(row.message_id, owners);
30360
+ }
30361
+ const result = copySessionStateForClone(db, parentSessionID, sessionId, forkCloneFilter(idMap, copiedToolCallIds, {
30362
+ sessionId,
30363
+ sequenceForId: (id) => store.sequenceForId(parentSessionID, id),
30364
+ matchingBodies: () => store.matchingForkBodies(parentSessionID, sessionId, throughSeq),
30365
+ acceptedGaps: (source, onConversionGap) => nonNarrativeStoredGapRanges(db, parentSessionID, source, (start, end) => readV2MessageRange2(store, parentSessionID, start, Math.min(end, idMap.parentOrdinals.size)), onConversionGap)
30366
+ }, toolOwners));
30114
30367
  if (result.kind === "destination-not-empty")
30115
30368
  return { kind: "destination-not-empty", parentSessionID };
30116
30369
  return { kind: "seeded", parentSessionID, pairedRows: idMap.parentToFork.size, result };
@@ -30281,6 +30534,7 @@ function isSessionNotFound(error) {
30281
30534
  return /not\s*found/i.test(label);
30282
30535
  }
30283
30536
  function createNativeHiddenChildren(host, removeSession, options) {
30537
+ const quiet = supportsQuietHiddenChildren(options.hostVersion);
30284
30538
  const removing = new Map;
30285
30539
  const remove = (child) => {
30286
30540
  const inFlight = removing.get(child.id);
@@ -30323,6 +30577,15 @@ function createNativeHiddenChildren(host, removeSession, options) {
30323
30577
  };
30324
30578
  const create = async (identity, role, model) => {
30325
30579
  const input = childCreateInput(identity, role, model);
30580
+ const directory = identity.directory;
30581
+ if (quiet) {
30582
+ if (!host.createHolder)
30583
+ throw new Error("OpenCode 2 background holder API is not wired");
30584
+ const placement = await hiddenRunPlacement(host.createHolder, directory);
30585
+ input.id = placement.id;
30586
+ input.parentID = placement.parentID;
30587
+ delete input.location;
30588
+ }
30326
30589
  const created = await host.create(input);
30327
30590
  if (!created.id)
30328
30591
  throw new Error("OpenCode 2 did not return a child session id");
@@ -30332,7 +30595,7 @@ function createNativeHiddenChildren(host, removeSession, options) {
30332
30595
  try {
30333
30596
  recordHiddenChild(options.db, {
30334
30597
  id: created.id,
30335
- directory: identity.directory,
30598
+ directory,
30336
30599
  created_at: createdAt,
30337
30600
  deadline_at: createdAt + identity.timeoutMs
30338
30601
  });
@@ -30358,17 +30621,22 @@ function createNativeHiddenChildren(host, removeSession, options) {
30358
30621
  throw storeError;
30359
30622
  }
30360
30623
  }
30361
- options.hook.registerChild(created.id, input.agent);
30362
- options.log(`[magic-context] hidden child ${created.id} created role=${role} keep_subagents=${options.keepSubagents}`);
30363
- return {
30624
+ const child = {
30364
30625
  id: created.id,
30365
30626
  role,
30366
30627
  generation: options.generation,
30367
30628
  title: roleTitle(role),
30368
30629
  model,
30369
30630
  created_at: createdAt,
30370
- directory: identity.directory
30631
+ directory
30371
30632
  };
30633
+ if (input.parentID && (created.id !== input.id || created.parentID !== input.parentID || !matchesHiddenRunLocation(directory, created.location?.directory))) {
30634
+ await remove(child);
30635
+ throw new Error(`OpenCode created a background run outside its holder at ${directory}`);
30636
+ }
30637
+ options.hook.registerChild(created.id, input.agent);
30638
+ options.log(`[magic-context] hidden child ${created.id} created role=${role} keep_subagents=${options.keepSubagents}`);
30639
+ return child;
30372
30640
  };
30373
30641
  const kept = (child) => keptUnderRetention(options.keepSubagents, child);
30374
30642
  return {
@@ -30867,6 +31135,7 @@ async function createV2HiddenCompletionExecutor(host, options) {
30867
31135
  db: options.db,
30868
31136
  hook: options.hook,
30869
31137
  generation,
31138
+ hostVersion: options.hostVersion,
30870
31139
  keepSubagents: options.keepSubagents === true,
30871
31140
  log: note,
30872
31141
  removalTimeoutMs: options.removalTimeoutMs
@@ -41460,6 +41729,55 @@ function createV2EmbeddingScope(initialProject) {
41460
41729
  };
41461
41730
  }
41462
41731
 
41732
+ // src/v2/hooks/fork-history-status.ts
41733
+ var logged = new Set;
41734
+ var toasted = new Set;
41735
+ var isGap = (error) => error?.startsWith("gap before message ") === true;
41736
+ var diagnoses = new WeakMap;
41737
+ function readForkHistoryGap(db, openReader, sessionID) {
41738
+ const rows = db.prepare(`SELECT sequence, start_message AS startMessage, end_message AS endMessage,
41739
+ rebase_status AS rebaseStatus FROM compartments WHERE session_id = ? ORDER BY sequence`).all(sessionID);
41740
+ if (!isGap(validateStoredCompartments(rows)) || rows.some(({ rebaseStatus }) => rebaseStatus === "unresolved")) {
41741
+ diagnoses.get(db)?.delete(sessionID);
41742
+ return false;
41743
+ }
41744
+ let cache = diagnoses.get(db);
41745
+ if (!cache) {
41746
+ cache = new BoundedSessionMap(1000);
41747
+ diagnoses.set(db, cache);
41748
+ }
41749
+ const notice = db.prepare("SELECT coordinate_rebase_notice AS text FROM session_meta WHERE session_id = ?").get(sessionID);
41750
+ const reader = openReader();
41751
+ let gap;
41752
+ try {
41753
+ const key = JSON.stringify([
41754
+ rows,
41755
+ notice?.text ?? null,
41756
+ reader.messageCountAndNewestId(sessionID)
41757
+ ]);
41758
+ const cached = cache.get(sessionID);
41759
+ if (cached?.key === key) {
41760
+ gap = cached.gap;
41761
+ } else {
41762
+ gap = Boolean(reader.forkOrigin(sessionID)) && isGap(validateStoredCompartments(rows, nonNarrativeStoredGapRanges(db, sessionID, rows, (from, to) => iterateV2MessageRange2(reader, sessionID, from, to))));
41763
+ cache.set(sessionID, { key, gap });
41764
+ }
41765
+ } finally {
41766
+ reader.close();
41767
+ }
41768
+ if (!gap)
41769
+ return false;
41770
+ if (!logged.has(sessionID)) {
41771
+ logged.add(sessionID);
41772
+ sessionLog2(sessionID, "v2 fork saved history has a gap; /ctx-recomp repairs this fork");
41773
+ }
41774
+ if (!toasted.has(sessionID) && isTuiConnected2(sessionID)) {
41775
+ toasted.add(sessionID);
41776
+ pushNotification2("toast", { message: renderUserFacingFailure("fork_history_gap", "plain"), variant: "warning" }, sessionID, { liveOnly: true });
41777
+ }
41778
+ return true;
41779
+ }
41780
+
41463
41781
  // src/v2/hooks/generate.ts
41464
41782
  import { createHash as createHash17 } from "node:crypto";
41465
41783
  var typedArrayName = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag)?.get;
@@ -54520,10 +54838,11 @@ Your active memories are already in <project-memory> as \`#id: fact\` lines. Wri
54520
54838
 
54521
54839
  Actions:
54522
54840
  - write: new memory (content + category).
54523
- - update: rewrite one memory whose fact changed (ids: [one], content; category optional to recategorize).
54841
+ - update: rewrite one memory whose fact changed (ids: [one], content; category: the current one to keep, a new one to recategorize).
54524
54842
  - archive: retire wrong or obsolete memories (ids: [one or more], optional reason).
54525
- - merge: collapse duplicates into one (ids: [two or more], content).
54843
+ - merge: collapse duplicates into one (ids: [two or more distinct ids of memories in the same category], content).
54526
54844
  - get: fetch by id (ids: 1–20), readable in every status.
54845
+ The call form that works on every host sends action, content, category and ids every time: argument-dropping providers only emit required fields. For get and archive pass content="" and any valid category; for write pass ids=[].
54527
54846
  Examples: category="CONFIG_VALUES", content="OpenCode source is at ~/Work/OSS/opencode" · category="CONSTRAINTS", content="Dashboard Tauri build needs RGBA PNGs, not grayscale"`;
54528
54847
  var DEFAULT_SEARCH_LIMIT = 10;
54529
54848
  // src/features/magic-context/memory/memory-visibility.ts
@@ -54780,13 +55099,13 @@ function updateMemoryContentInCurrentTransaction(db, memory, content, normalized
54780
55099
  }
54781
55100
  var ctxMemoryArgsShape = {
54782
55101
  action: tool.schema.enum([...CTX_MEMORY_ACTIONS]).describe("write | update | archive | merge | get"),
54783
- content: tool.schema.string().describe("The memory text — one standalone fact (write, update, merge)."),
54784
- category: tool.schema.enum([...V2_MEMORY_CATEGORIES]).describe("Kind of fact (required for write; on update/merge, pass the memory's current category to keep it)."),
54785
- ids: tool.schema.array(tool.schema.number()).describe("Memory ids from <project-memory>: one for update, one or more for archive, two or more for merge, 1–20 for get."),
55102
+ content: tool.schema.string().describe("Send on every call — the memory text for write, update and merge; pass an empty string for archive and get."),
55103
+ category: tool.schema.enum([...V2_MEMORY_CATEGORIES]).describe("Send on every call — the fact's kind for write; on update/merge, the memory's current category to keep it; archive and get ignore it, so pass any valid category."),
55104
+ ids: tool.schema.array(tool.schema.number()).describe("Send on every call — one id for update, one or more for archive, two or more distinct ids of memories in the same category for merge, 1–20 for get; write takes an empty list."),
54786
55105
  reason: tool.schema.string().optional().describe("Why it is being archived (optional).")
54787
55106
  };
54788
55107
  var ctxMemoryListArgsShape = {
54789
- category: tool.schema.enum([...V2_MEMORY_CATEGORIES]).optional().describe("Kind of fact (required for write; on update/merge optional, omitted keeps the current category)."),
55108
+ category: tool.schema.enum([...V2_MEMORY_CATEGORIES]).optional().describe("Filter listed memories to this category (optional)."),
54790
55109
  limit: tool.schema.number().optional().describe("Max results for list (default 10).")
54791
55110
  };
54792
55111
  var ctxMemoryArgsSchema = tool.schema.object({
@@ -57268,6 +57587,7 @@ async function registerContext(context) {
57268
57587
  await cleanupLegacyOnce(database);
57269
57588
  return createV2HiddenCompletionExecutor({
57270
57589
  ...context.session,
57590
+ createHolder: (input) => context.session.create(input),
57271
57591
  watchModelActivity: (sessionID, onOutput) => hiddenModelActivity.watch(sessionID, onOutput),
57272
57592
  get: async (input) => {
57273
57593
  const session = await context.session.get(input);
@@ -57294,6 +57614,7 @@ async function registerContext(context) {
57294
57614
  projectIdentity: resolveProjectIdentityForSession(directory, config.allow_home_project) ?? "",
57295
57615
  directory,
57296
57616
  hook: hiddenChildHook,
57617
+ hostVersion: context.app?.version,
57297
57618
  keepSubagents: config.keep_subagents === true,
57298
57619
  ensureAgent: () => hiddenAgentsReady ??= context.agent.reload(),
57299
57620
  modelCatalog: () => Promise.resolve(context.model.list()),
@@ -58007,6 +58328,9 @@ async function registerContext(context) {
58007
58328
  tagger,
58008
58329
  ...createV2ThresholdDeps(config),
58009
58330
  contextUsageMap: usage,
58331
+ hostProjectBindingNotice: (sessionID, message) => {
58332
+ pushLiveNotification2("toast", { message, variant: "warning" }, sessionID);
58333
+ },
58010
58334
  hostInputEstimate: (sessionID) => checkpointInputEstimates.get(sessionID),
58011
58335
  onPassPermission: (sessionID, permission) => {
58012
58336
  checkpointPassPermissions.set(sessionID, permission);
@@ -58772,6 +59096,7 @@ async function registerContext(context) {
58772
59096
  hiddenCompletionExecutor: storageOpenedAtBoot ? hiddenCompletionExecutor : lateHiddenExecutor,
58773
59097
  compactionMarkerStrategy: v2CompactionMarkerStrategy,
58774
59098
  prepareHistorySession,
59099
+ readForkHistoryGap: (database, sessionID) => readForkHistoryGap(database, openStoreReader, sessionID),
58775
59100
  readSessionDirectory: async (sessionID) => {
58776
59101
  try {
58777
59102
  return (await context.session.get({ sessionID })).location?.directory ?? null;