@cortexkit/opencode-magic-context 0.49.6 → 0.49.7

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 (153) hide show
  1. package/dist/auto-search-worker.js +10 -7
  2. package/dist/{compaction-marker-candidates-cz72pm1t.js → compaction-marker-candidates-a0edbqrr.js} +2 -2
  3. package/dist/compaction-marker-candidates-worker.js +2 -2
  4. package/dist/{conflict-warning-hook-1jq1rxx7.js → conflict-warning-hook-myk5hbt9.js} +5 -5
  5. package/dist/{context-ae3gxdye.js → context-ffr7e0g7.js} +46 -34
  6. package/dist/{embedding-backfill-dtjmyktb.js → embedding-backfill-re16xncd.js} +6 -6
  7. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  8. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +6 -3
  9. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  10. package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts +7 -1
  11. package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts.map +1 -1
  12. package/dist/features/magic-context/dreamer/map-memories.d.ts +2 -2
  13. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/primer-seed.d.ts +2 -0
  15. package/dist/features/magic-context/dreamer/primer-seed.d.ts.map +1 -1
  16. package/dist/features/magic-context/dreamer/refresh-primers.d.ts +2 -2
  17. package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
  18. package/dist/features/magic-context/storage-meta-persisted.d.ts +10 -3
  19. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  20. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  21. package/dist/features/magic-context/storage-replay-document.d.ts +4 -0
  22. package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/apply-operations.d.ts +7 -0
  24. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  25. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
  26. package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
  27. package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
  28. package/dist/hooks/magic-context/note-nudger.d.ts +5 -3
  29. package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
  30. package/dist/hooks/magic-context/postprocess-read-cache.d.ts.map +1 -1
  31. package/dist/hooks/magic-context/read-session-chunk.d.ts +7 -0
  32. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  33. package/dist/hooks/magic-context/replay-committed-drops.d.ts +9 -0
  34. package/dist/hooks/magic-context/replay-committed-drops.d.ts.map +1 -0
  35. package/dist/hooks/magic-context/rust-lkg-freeze-registry.d.ts +2 -2
  36. package/dist/hooks/magic-context/rust-lkg-freeze-registry.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/rust-mode-transform.d.ts +3 -0
  38. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/rust-served-raw.d.ts +29 -0
  40. package/dist/hooks/magic-context/rust-served-raw.d.ts.map +1 -0
  41. package/dist/hooks/magic-context/strip-content.d.ts +23 -24
  42. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  43. package/dist/hooks/magic-context/tag-messages.d.ts +2 -0
  44. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/tool-drop-target.d.ts +2 -0
  46. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  47. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  48. package/dist/{index-6q5h70h2.js → index-0gyq3djm.js} +1 -1
  49. package/dist/{index-vnjhmkwk.js → index-37q80veb.js} +1 -1
  50. package/dist/{index-besxhcsh.js → index-4btknbqh.js} +9 -8
  51. package/dist/{index-vh3e2mvr.js → index-5tbvdff4.js} +59 -28
  52. package/dist/{index-cm4hmxyk.js → index-9yyqq3mm.js} +1 -1
  53. package/dist/{index-ab3bgm2m.js → index-a8acx4gc.js} +2 -2
  54. package/dist/{index-j55vn694.js → index-ax2jhztn.js} +1 -1
  55. package/dist/{index-zgzdm6dg.js → index-ebnngykq.js} +145 -94
  56. package/dist/{index-g9exahnx.js → index-g8qbdb03.js} +1 -1
  57. package/dist/{index-ch08qwgd.js → index-j58gqrn2.js} +65 -65
  58. package/dist/{index-xqyj5c85.js → index-j5hce1ab.js} +2 -2
  59. package/dist/{index-0nnd4bry.js → index-j8epsc0g.js} +34 -13
  60. package/dist/{index-vztbgcdk.js → index-n5a170gs.js} +227 -38
  61. package/dist/{index-s0gsmthp.js → index-n7kwfw2r.js} +4 -4
  62. package/dist/{index-ck6y3td2.js → index-rwmpkss5.js} +3 -3
  63. package/dist/{index-bg5qqene.js → index-rzmjkdd6.js} +1 -1
  64. package/dist/{index-9s58tq95.js → index-sf94at64.js} +3 -3
  65. package/dist/{index-f3dnvnw6.js → index-sh91t19a.js} +1 -1
  66. package/dist/{index-mj1fgfrk.js → index-tagss15p.js} +857 -125
  67. package/dist/{index-1j8jcjpa.js → index-tmtty2x5.js} +1 -1
  68. package/dist/{index-hr64sth2.js → index-vt4sf4ep.js} +1 -1
  69. package/dist/{index-9m7bn21d.js → index-w4mw92w3.js} +1 -1
  70. package/dist/{index-7q1m1qjk.js → index-w6bd03dc.js} +1 -1
  71. package/dist/{index-a796ct3s.js → index-w6vr754t.js} +4 -4
  72. package/dist/{index-1xaw2pq8.js → index-wq16ahsn.js} +5 -5
  73. package/dist/index.js +36 -36
  74. package/dist/{message-index-bounded-630j53ps.js → message-index-bounded-04rycpx4.js} +9 -9
  75. package/dist/{message-index-c84wm2g0.js → message-index-rqtse28y.js} +9 -9
  76. package/dist/{message-time-backfill-8kj57qe3.js → message-time-backfill-a5ytnp53.js} +1 -1
  77. package/dist/migration-worker.js +6 -6
  78. package/dist/plugin/messages-transform.d.ts.map +1 -1
  79. package/dist/{project-embedding-registry-vv59t7ah.js → project-embedding-registry-k0sd9k7v.js} +5 -5
  80. package/dist/raw-ordinal-warmup-worker.js +17 -15
  81. package/dist/{read-session-chunk-t3vjd0h0.js → read-session-chunk-h1btx938.js} +7 -5
  82. package/dist/{read-session-raw-gf7eytnm.js → read-session-raw-vdf4wh78.js} +2 -2
  83. package/dist/{recomp-orchestrator-1d08g57a.js → recomp-orchestrator-trcgmm23.js} +20 -20
  84. package/dist/{search-kth2p6cc.js → search-3rbdx6hw.js} +16 -16
  85. package/dist/{send-session-notification-3j6krd4w.js → send-session-notification-2tp44tfa.js} +4 -4
  86. package/dist/shared/processed-image-eligibility.d.ts +22 -0
  87. package/dist/shared/processed-image-eligibility.d.ts.map +1 -0
  88. package/dist/shared/recovery-reasoning-prefix.d.ts +9 -0
  89. package/dist/shared/recovery-reasoning-prefix.d.ts.map +1 -0
  90. package/dist/shared/sqlite.d.ts +1 -1
  91. package/dist/shared/sqlite.d.ts.map +1 -1
  92. package/dist/shared/tag-transcript.d.ts +9 -0
  93. package/dist/shared/tag-transcript.d.ts.map +1 -1
  94. package/dist/{sqlite-d7edbk1s.js → sqlite-j3tvg8r0.js} +1 -1
  95. package/dist/{storage-memory-af5zdz98.js → storage-memory-8168bgef.js} +2 -2
  96. package/dist/{storage-tags-dyj7mmbq.js → storage-tags-61z5j2f9.js} +2 -2
  97. package/dist/tools/ctx-expand/search-archive.d.ts +4 -0
  98. package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -0
  99. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  100. package/dist/{transform-postprocess-phase-bv3kb5s1.js → transform-postprocess-phase-7qts7h54.js} +20 -20
  101. package/dist/v2/auto-search-worker.js +10 -7
  102. package/dist/v2/{compaction-marker-candidates-6gqp5wrc.js → compaction-marker-candidates-6nypjkpf.js} +2 -2
  103. package/dist/v2/compaction-marker-candidates-worker.js +2 -2
  104. package/dist/v2/{context-p8f2shp1.js → context-xq4rtywr.js} +1019 -233
  105. package/dist/v2/{embedding-backfill-cg4rv90f.js → embedding-backfill-xd9ygzgd.js} +6 -6
  106. package/dist/v2/hooks/payload.d.ts.map +1 -1
  107. package/dist/v2/{message-index-3ws17x1g.js → message-index-8e5z2xx8.js} +9 -9
  108. package/dist/v2/{message-index-bounded-yzxmf6vp.js → message-index-bounded-5vh1h2g7.js} +9 -9
  109. package/dist/v2/{message-time-backfill-5nf10c65.js → message-time-backfill-2z365239.js} +1 -1
  110. package/dist/v2/migration-worker.js +6 -6
  111. package/dist/v2/{project-embedding-registry-rsnf2263.js → project-embedding-registry-b77awytr.js} +5 -5
  112. package/dist/v2/raw-ordinal-warmup-worker.js +17 -15
  113. package/dist/v2/{read-session-chunk-vtb0w2kd.js → read-session-chunk-4sat83cx.js} +7 -5
  114. package/dist/v2/{read-session-raw-gpcddemt.js → read-session-raw-a3hw9jsp.js} +2 -2
  115. package/dist/v2/{recomp-orchestrator-v64r4s4r.js → recomp-orchestrator-n11zv1f1.js} +19 -19
  116. package/dist/v2/{search-bpa4fxq1.js → search-mvgqtkkz.js} +16 -16
  117. package/dist/v2/{send-session-notification-5aj2j7vf.js → send-session-notification-ppgc8qdz.js} +4 -4
  118. package/dist/v2/{server-wrem2nmz.js → server-1rfgbjfn.js} +1 -1
  119. package/dist/v2/{server-qn23p4h7.js → server-7srtwsa4.js} +5 -5
  120. package/dist/v2/{server-cm4hmxyk.js → server-9yyqq3mm.js} +1 -1
  121. package/dist/v2/{server-yezz0cp2.js → server-brhj8qtd.js} +1 -1
  122. package/dist/v2/{server-387vkhjq.js → server-dd0nja67.js} +1 -1
  123. package/dist/v2/{server-keswwkvv.js → server-fpqe39as.js} +1 -1
  124. package/dist/v2/{server-158ehmk2.js → server-fw31krgq.js} +3 -3
  125. package/dist/v2/{server-fby0cxbq.js → server-gtv9wbhq.js} +227 -38
  126. package/dist/v2/{server-ww9nr8pe.js → server-hcvcxzx7.js} +2 -2
  127. package/dist/v2/{server-0nnd4bry.js → server-j8epsc0g.js} +34 -13
  128. package/dist/v2/{server-x2r63c0x.js → server-jdwd03ep.js} +4 -4
  129. package/dist/v2/{server-btgnsv7w.js → server-kdrezdy0.js} +1 -1
  130. package/dist/v2/{server-7skbfb81.js → server-mv1w7t6z.js} +61 -30
  131. package/dist/v2/{server-aa9w15cs.js → server-nfan6zb6.js} +65 -65
  132. package/dist/v2/{server-9zqewm6g.js → server-qcw43339.js} +1 -1
  133. package/dist/v2/{server-f9py7s7a.js → server-sy4b1sra.js} +1 -1
  134. package/dist/v2/{server-09g9pkvx.js → server-v4fwha43.js} +9 -8
  135. package/dist/v2/{server-yd01snxq.js → server-w3zeywp1.js} +1 -1
  136. package/dist/v2/{server-4tn95znb.js → server-wkdgjjch.js} +1 -1
  137. package/dist/v2/{server-6a9mxnb2.js → server-x08d1xf3.js} +1 -1
  138. package/dist/v2/server.js +4 -4
  139. package/dist/v2/{sqlite-d7edbk1s.js → sqlite-j3tvg8r0.js} +1 -1
  140. package/dist/v2/{storage-memory-af5zdz98.js → storage-memory-8168bgef.js} +2 -2
  141. package/dist/v2/{storage-tags-d47bpaqa.js → storage-tags-j2fzq3sw.js} +2 -2
  142. package/dist/v2/{wrapup-orchestrator-cahk37n7.js → wrapup-orchestrator-s92ebfzv.js} +19 -19
  143. package/dist/{wrapup-orchestrator-mqp0v195.js → wrapup-orchestrator-df61jmz9.js} +21 -21
  144. package/package.json +3 -3
  145. package/src/shared/processed-image-eligibility.test.ts +68 -0
  146. package/src/shared/processed-image-eligibility.ts +41 -0
  147. package/src/shared/processed-image-position-review.json +20 -0
  148. package/src/shared/processed-image-position-review.test.ts +19 -0
  149. package/src/shared/recovery-reasoning-prefix.test.ts +34 -0
  150. package/src/shared/recovery-reasoning-prefix.ts +35 -0
  151. package/src/shared/sqlite-writer-diagnostics.test.ts +31 -0
  152. package/src/shared/sqlite.ts +63 -22
  153. package/src/shared/tag-transcript.ts +118 -0
package/dist/v2/server.js CHANGED
@@ -7870,7 +7870,7 @@ var require_src2 = __commonJS(function(exports, module) {
7870
7870
  // package.json
7871
7871
  var package_default = {
7872
7872
  name: "@cortexkit/opencode-magic-context",
7873
- version: "0.49.6",
7873
+ version: "0.49.7",
7874
7874
  type: "module",
7875
7875
  description: "OpenCode plugin for Magic Context — cross-session memory and context management",
7876
7876
  main: "dist/index.js",
@@ -7913,8 +7913,8 @@ var package_default = {
7913
7913
  "check:tui-compiled": 'git diff --exit-code -- src/tui-compiled && test -z "$(git status --porcelain -- src/tui-compiled)"',
7914
7914
  "check:transformers-node-wasm": "bun scripts/verify-transformers-node-wasm.ts",
7915
7915
  typecheck: "tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit && tsc -p tsconfig.scripts.json",
7916
- test: "bun ../../scripts/check-bun.mjs && bun install --frozen-lockfile && BUN_JSC_useOMGJIT=0 bun test --parallel=4 --timeout 30000",
7917
- "test:serial": "bun install --frozen-lockfile && BUN_JSC_useOMGJIT=0 bun test --timeout 30000",
7916
+ test: "bun ../../scripts/check-bun.mjs && bun install --frozen-lockfile && MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test --parallel=4 --timeout 30000",
7917
+ "test:serial": "bun install --frozen-lockfile && MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test --timeout 30000",
7918
7918
  "test:parallel:probe": "bun scripts/verify-parallel-db-isolation.ts",
7919
7919
  lint: "bun ../../scripts/check-bun.mjs && biome check .",
7920
7920
  "lint:fix": "biome check --write .",
@@ -8186,7 +8186,7 @@ async function setup(context) {
8186
8186
  log2("v2 setup() called on a host without session.hook; v1 server lane owns this host, v2 lane inert");
8187
8187
  return async () => {};
8188
8188
  }
8189
- const { registerContext } = await import("./context-p8f2shp1.js");
8189
+ const { registerContext } = await import("./context-xq4rtywr.js");
8190
8190
  setHarness2("opencode2");
8191
8191
  bindStaleBuildNotice({}, import.meta.url, "opencode2");
8192
8192
  const duties = await registerContext(context);
@@ -20,7 +20,7 @@ import {
20
20
  releaseIndexOwner2,
21
21
  withIndexChunk2,
22
22
  yieldIndexChunk2
23
- } from "./server-0nnd4bry.js";
23
+ } from "./server-j8epsc0g.js";
24
24
  export {
25
25
  Database2 as Database,
26
26
  SqliteAcquisitionBusyError2 as SqliteAcquisitionBusyError,
@@ -31,10 +31,10 @@ import {
31
31
  deleteMemory2,
32
32
  getMemoryCount2,
33
33
  getMemoryCountsByStatus2
34
- } from "./server-cm4hmxyk.js";
34
+ } from "./server-9yyqq3mm.js";
35
35
  import"./server-4dhv7mqz.js";
36
36
  import"./server-fr0wbhdn.js";
37
- import"./server-0nnd4bry.js";
37
+ import"./server-j8epsc0g.js";
38
38
  export {
39
39
  COLUMN_MAP2 as COLUMN_MAP,
40
40
  ModuleMemoryAuthorityError2 as ModuleMemoryAuthorityError,
@@ -60,10 +60,10 @@ import {
60
60
  adoptNullOwnerToolTag2,
61
61
  getCandidateToolOwners2,
62
62
  pickNearestPriorOwner2
63
- } from "./server-yd01snxq.js";
63
+ } from "./server-w3zeywp1.js";
64
64
  import"./server-1zx87sdm.js";
65
65
  import"./server-6byqfbqf.js";
66
- import"./server-0nnd4bry.js";
66
+ import"./server-j8epsc0g.js";
67
67
  import"./server-kzns2hbz.js";
68
68
  import"./server-t4k4qexw.js";
69
69
  import"./server-pavzsdc6.js";
@@ -2,7 +2,7 @@ import"./server-pavzsdc6.js";
2
2
  import {
3
3
  sessionLog2
4
4
  } from "./server-t4k4qexw.js";
5
- import"./server-wrem2nmz.js";
5
+ import"./server-1rfgbjfn.js";
6
6
  import {
7
7
  COMPARTMENT_LEASE_RENEWAL_MS,
8
8
  acquireCompartmentLease,
@@ -19,13 +19,13 @@ import {
19
19
  registerActiveCompartmentRun,
20
20
  setRecompStarting2,
21
21
  setRecompTerminal2
22
- } from "./server-7skbfb81.js";
22
+ } from "./server-mv1w7t6z.js";
23
23
  import"./server-kzns2hbz.js";
24
24
  import"./server-hb6xhh9q.js";
25
- import"./server-0nnd4bry.js";
26
- import"./server-yezz0cp2.js";
27
- import"./server-keswwkvv.js";
28
- import"./server-qn23p4h7.js";
25
+ import"./server-j8epsc0g.js";
26
+ import"./server-brhj8qtd.js";
27
+ import"./server-fpqe39as.js";
28
+ import"./server-7srtwsa4.js";
29
29
  import {
30
30
  getWrapupInProgressState,
31
31
  acquireWrapupInProgress,
@@ -34,39 +34,39 @@ import {
34
34
  getHistorianFailureState,
35
35
  clearEmergencyRecovery,
36
36
  prepareRawSessionOrdinals2
37
- } from "./server-fby0cxbq.js";
37
+ } from "./server-gtv9wbhq.js";
38
38
  import"./server-6byqfbqf.js";
39
- import"./server-09g9pkvx.js";
39
+ import"./server-v4fwha43.js";
40
40
  import"./server-1zx87sdm.js";
41
- import"./server-yd01snxq.js";
41
+ import"./server-w3zeywp1.js";
42
42
  import"./server-cw6521wn.js";
43
43
  import"./server-51779zs2.js";
44
- import"./server-387vkhjq.js";
44
+ import"./server-dd0nja67.js";
45
45
  import"./server-2ra6pwf3.js";
46
- import"./server-4tn95znb.js";
46
+ import"./server-wkdgjjch.js";
47
47
  import"./server-7ekna9zs.js";
48
48
  import"./server-fr0wbhdn.js";
49
- import"./server-ww9nr8pe.js";
50
- import"./server-btgnsv7w.js";
51
- import"./server-158ehmk2.js";
49
+ import"./server-hcvcxzx7.js";
50
+ import"./server-kdrezdy0.js";
51
+ import"./server-fw31krgq.js";
52
52
  import"./server-fb3zxn06.js";
53
- import"./server-x2r63c0x.js";
53
+ import"./server-jdwd03ep.js";
54
54
  import {
55
55
  pushNotification2
56
56
  } from "./server-x8a7jmkh.js";
57
- import"./server-6a9mxnb2.js";
57
+ import"./server-x08d1xf3.js";
58
58
  import"./server-qt1qqasc.js";
59
59
  import"./server-4dhv7mqz.js";
60
60
  import"./server-ras2sxnc.js";
61
- import"./server-f9py7s7a.js";
62
- import"./server-cm4hmxyk.js";
61
+ import"./server-sy4b1sra.js";
62
+ import"./server-9yyqq3mm.js";
63
63
  import"./server-d6g4whc2.js";
64
64
  import"./server-vb7pbd9p.js";
65
65
  import"./server-t528t8qm.js";
66
66
  import"./server-676xw7at.js";
67
67
  import {
68
68
  sendStatusNotification2
69
- } from "./server-9zqewm6g.js";
69
+ } from "./server-qcw43339.js";
70
70
  import"./server-3t0q2cqx.js";
71
71
 
72
72
  // src/hooks/magic-context/wrapup-orchestrator.ts
@@ -1,43 +1,43 @@
1
1
  import {
2
2
  runManagedWrapup2
3
- } from "./index-a796ct3s.js";
4
- import"./index-ck6y3td2.js";
5
- import"./index-vh3e2mvr.js";
6
- import"./index-f3dnvnw6.js";
3
+ } from "./index-w6vr754t.js";
4
+ import"./index-rwmpkss5.js";
5
+ import"./index-5tbvdff4.js";
6
+ import"./index-sh91t19a.js";
7
7
  import"./index-sd3egckz.js";
8
- import"./index-s0gsmthp.js";
9
- import"./index-1xaw2pq8.js";
10
- import"./index-7q1m1qjk.js";
11
- import"./index-cm4hmxyk.js";
12
- import"./index-9s58tq95.js";
13
- import"./index-j55vn694.js";
8
+ import"./index-n7kwfw2r.js";
9
+ import"./index-wq16ahsn.js";
10
+ import"./index-w6bd03dc.js";
11
+ import"./index-9yyqq3mm.js";
12
+ import"./index-sf94at64.js";
13
+ import"./index-ax2jhztn.js";
14
14
  import"./index-4dhv7mqz.js";
15
15
  import"./index-w23dh319.js";
16
- import"./index-hr64sth2.js";
16
+ import"./index-vt4sf4ep.js";
17
17
  import"./index-qt1qqasc.js";
18
18
  import"./index-x8a7jmkh.js";
19
19
  import"./index-tqf7yg27.js";
20
20
  import"./index-gbmqa9x9.js";
21
21
  import"./index-vkbqdnkj.js";
22
- import"./index-besxhcsh.js";
22
+ import"./index-4btknbqh.js";
23
23
  import"./index-fb3zxn06.js";
24
- import"./index-xqyj5c85.js";
25
- import"./index-9m7bn21d.js";
24
+ import"./index-j5hce1ab.js";
25
+ import"./index-w4mw92w3.js";
26
26
  import"./index-fr0wbhdn.js";
27
- import"./index-g9exahnx.js";
28
- import"./index-bg5qqene.js";
29
- import"./index-vztbgcdk.js";
30
- import"./index-1j8jcjpa.js";
27
+ import"./index-g8qbdb03.js";
28
+ import"./index-rzmjkdd6.js";
29
+ import"./index-n5a170gs.js";
30
+ import"./index-tmtty2x5.js";
31
31
  import"./index-1zx87sdm.js";
32
- import"./index-ab3bgm2m.js";
33
- import"./index-vnjhmkwk.js";
32
+ import"./index-a8acx4gc.js";
33
+ import"./index-37q80veb.js";
34
34
  import"./index-v0p37hm2.js";
35
35
  import"./index-k6xvbj2e.js";
36
36
  import"./index-h2wc01qk.js";
37
37
  import"./index-1bt88epp.js";
38
38
  import"./index-58e3y90n.js";
39
39
  import"./index-4mjhqadz.js";
40
- import"./index-0nnd4bry.js";
40
+ import"./index-j8epsc0g.js";
41
41
  import"./index-qx53vezw.js";
42
42
  import"./index-nsjyysj0.js";
43
43
  import"./index-0sahzkwr.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-magic-context",
3
- "version": "0.49.6",
3
+ "version": "0.49.7",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",
@@ -43,8 +43,8 @@
43
43
  "check:tui-compiled": "git diff --exit-code -- src/tui-compiled && test -z \"$(git status --porcelain -- src/tui-compiled)\"",
44
44
  "check:transformers-node-wasm": "bun scripts/verify-transformers-node-wasm.ts",
45
45
  "typecheck": "tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit && tsc -p tsconfig.scripts.json",
46
- "test": "bun ../../scripts/check-bun.mjs && bun install --frozen-lockfile && BUN_JSC_useOMGJIT=0 bun test --parallel=4 --timeout 30000",
47
- "test:serial": "bun install --frozen-lockfile && BUN_JSC_useOMGJIT=0 bun test --timeout 30000",
46
+ "test": "bun ../../scripts/check-bun.mjs && bun install --frozen-lockfile && MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test --parallel=4 --timeout 30000",
47
+ "test:serial": "bun install --frozen-lockfile && MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test --timeout 30000",
48
48
  "test:parallel:probe": "bun scripts/verify-parallel-db-isolation.ts",
49
49
  "lint": "bun ../../scripts/check-bun.mjs && biome check .",
50
50
  "lint:fix": "biome check --write .",
@@ -0,0 +1,68 @@
1
+ import { expect, test } from "bun:test";
2
+ import { createProcessedImageEligibility } from "./processed-image-eligibility";
3
+
4
+ const messages = ["old", "image", "answer", "tail"];
5
+
6
+ test("image position age inherits its next positive tag, never zero or an earlier tag", () => {
7
+ const policy = createProcessedImageEligibility(
8
+ messages,
9
+ new Map([
10
+ ["old", 1],
11
+ ["answer", 6],
12
+ ]),
13
+ { watermark: 1 },
14
+ );
15
+ expect(policy.ageTags.get("image")).toBe(6);
16
+ expect(policy.mayStrip("image")).toBe(false);
17
+ expect(policy.ageTags.has("tail")).toBe(false);
18
+ expect(policy.mayStrip("tail")).toBe(false);
19
+ const own = createProcessedImageEligibility(
20
+ messages,
21
+ new Map([
22
+ ["image", 3],
23
+ ["answer", 6],
24
+ ]),
25
+ { watermark: 4 },
26
+ );
27
+ expect(own.ageTags.get("image")).toBe(3);
28
+ expect(own.mayStrip("image")).toBe(true);
29
+ });
30
+
31
+ test("answered image-only positions outside the protected window are eligible", () => {
32
+ const policy = createProcessedImageEligibility(
33
+ messages,
34
+ new Map([
35
+ ["answer", 3],
36
+ ["tail", 5],
37
+ ]),
38
+ { watermark: 4, protectedCutoff: 5, contextPercentage: 94.99 },
39
+ );
40
+ expect(policy.ageTags.get("image")).toBe(3);
41
+ expect(policy.mayStrip("image")).toBe(true);
42
+ });
43
+
44
+ test("image positions inside the protected window stay below the 95 percent emergency", () => {
45
+ const policy = createProcessedImageEligibility(messages, new Map([["answer", 6]]), {
46
+ watermark: 10,
47
+ protectedCutoff: 5,
48
+ contextPercentage: 94.99,
49
+ });
50
+ expect(policy.mayStrip("image")).toBe(false);
51
+ });
52
+
53
+ test("image positions follow emergency drops when the newest window yields at 95 percent", () => {
54
+ for (const contextPercentage of [95, 99]) {
55
+ const policy = createProcessedImageEligibility(messages, new Map([["answer", 6]]), {
56
+ watermark: 10,
57
+ protectedCutoff: 5,
58
+ contextPercentage,
59
+ });
60
+ expect(policy.mayStrip("image")).toBe(true);
61
+ const notDroppedYet = createProcessedImageEligibility(messages, new Map([["answer", 11]]), {
62
+ watermark: 10,
63
+ protectedCutoff: 5,
64
+ contextPercentage,
65
+ });
66
+ expect(notDroppedYet.mayStrip("image")).toBe(false);
67
+ }
68
+ });
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Shared processed-image age and recency policy for both OpenCode adapters.
3
+ * Use the owning message's positive maximum tag; an untagged image-only message
4
+ * inherits the next positive tagged message after it, never age zero or a tag
5
+ * from an earlier message. Without either tag, retain the image at the live tail.
6
+ * A positive dropped-tag watermark must cover that position. Below 95% usage,
7
+ * retain every position at or beyond the protected newest-window cutoff. At
8
+ * 95% and above only that window yields, exactly as for emergency tool drops;
9
+ * independent per-tool protections still apply. Content before retained provider-signed
10
+ * thinking must stay unchanged unless an existing whole-turn rewrite removes that
11
+ * thinking first. Callers enforce these protections, later-assistant/stable-id checks, durable
12
+ * persistence and rewrite-only discovery. Frozen replay bypasses eligibility.
13
+ */
14
+ export function createProcessedImageEligibility<T>(
15
+ messages: readonly T[],
16
+ messageTagNumbers: ReadonlyMap<T, number>,
17
+ options: { watermark: number; protectedCutoff?: number | null; contextPercentage?: number },
18
+ ): { ageTags: ReadonlyMap<T, number>; mayStrip: (message: T) => boolean } {
19
+ const ageTags = new Map<T, number>();
20
+ let nextTag: number | undefined;
21
+ for (let index = messages.length - 1; index >= 0; index--) {
22
+ const message = messages[index];
23
+ const ownTag = messageTagNumbers.get(message);
24
+ if (ownTag !== undefined && Number.isFinite(ownTag) && ownTag > 0) nextTag = ownTag;
25
+ if (nextTag !== undefined) ageTags.set(message, nextTag);
26
+ }
27
+ return {
28
+ ageTags,
29
+ mayStrip: (message) => {
30
+ const age = ageTags.get(message);
31
+ return (
32
+ options.watermark > 0 &&
33
+ age !== undefined &&
34
+ age <= options.watermark &&
35
+ ((options.contextPercentage ?? 0) >= 95 ||
36
+ options.protectedCutoff == null ||
37
+ age < options.protectedCutoff)
38
+ );
39
+ },
40
+ };
41
+ }
@@ -0,0 +1,20 @@
1
+ [
2
+ { "name": "own maximum wins over a later smaller tag", "tags": [[2, 10, 4], [3]], "target": 0, "watermark": 8, "cutoff": null, "percentage": 60, "age": 10, "eligible": false },
3
+ { "name": "own maximum at watermark", "tags": [[2, 10, 4], [30]], "target": 0, "watermark": 10, "cutoff": null, "percentage": 60, "age": 10, "eligible": true },
4
+ { "name": "first later tag not largest later tag", "tags": [[], [3], [20]], "target": 0, "watermark": 3, "cutoff": null, "percentage": 60, "age": 3, "eligible": true },
5
+ { "name": "first later message contributes its own maximum", "tags": [[], [2, 9], [3]], "target": 0, "watermark": 5, "cutoff": null, "percentage": 60, "age": 9, "eligible": false },
6
+ { "name": "skip empty and zero tags when looking forward", "tags": [[1], [], [0], [4]], "target": 1, "watermark": 4, "cutoff": null, "percentage": 60, "age": 4, "eligible": true },
7
+ { "name": "zero own tag inherits later positive", "tags": [[0], [7]], "target": 0, "watermark": 6, "cutoff": null, "percentage": 60, "age": 7, "eligible": false },
8
+ { "name": "preceding tag cannot age live tail", "tags": [[1], [], []], "target": 1, "watermark": 100, "cutoff": null, "percentage": 60, "age": null, "eligible": false },
9
+ { "name": "all untagged is ineligible", "tags": [[], []], "target": 0, "watermark": 100, "cutoff": null, "percentage": 60, "age": null, "eligible": false },
10
+ { "name": "watermark zero even with emergency", "tags": [[], [1]], "target": 0, "watermark": 0, "cutoff": 1, "percentage": 95, "age": 1, "eligible": false },
11
+ { "name": "age above watermark even with emergency", "tags": [[], [7]], "target": 0, "watermark": 6, "cutoff": 1, "percentage": 100, "age": 7, "eligible": false },
12
+ { "name": "cutoff inclusive at 94.99 percent", "tags": [[5], [8]], "target": 0, "watermark": 9, "cutoff": 5, "percentage": 94.99, "age": 5, "eligible": false },
13
+ { "name": "inside cutoff is a range not set membership", "tags": [[], [6]], "target": 0, "watermark": 9, "cutoff": 5, "percentage": 60, "age": 6, "eligible": false },
14
+ { "name": "below cutoff is eligible", "tags": [[4], [8]], "target": 0, "watermark": 9, "cutoff": 5, "percentage": 94.99, "age": 4, "eligible": true },
15
+ { "name": "exactly 95 waives cutoff", "tags": [[], [6]], "target": 0, "watermark": 9, "cutoff": 5, "percentage": 95, "age": 6, "eligible": true },
16
+ { "name": "above 95 waives cutoff", "tags": [[5], [8]], "target": 0, "watermark": 9, "cutoff": 5, "percentage": 95.01, "age": 5, "eligible": true },
17
+ { "name": "emergency cannot invent tail age", "tags": [[1], []], "target": 1, "watermark": 100, "cutoff": 1, "percentage": 100, "age": null, "eligible": false },
18
+ { "name": "own positive tag overrides later greater tag", "tags": [[2], [20]], "target": 0, "watermark": 2, "cutoff": 3, "percentage": 60, "age": 2, "eligible": true },
19
+ { "name": "last message with own tag is aged", "tags": [[1], [4]], "target": 1, "watermark": 4, "cutoff": null, "percentage": 60, "age": 4, "eligible": true }
20
+ ]
@@ -0,0 +1,19 @@
1
+ import { expect, test } from "bun:test";
2
+ import { createProcessedImageEligibility } from "./processed-image-eligibility";
3
+ import cases from "./processed-image-position-review.json";
4
+
5
+ // OpenCode, Rust and Pi can reuse these cases: each row supplies per-message
6
+ // tag numbers rather than provider-specific message objects or image encodings.
7
+ for (const row of cases) {
8
+ test(`independent image position table: ${row.name}`, () => {
9
+ const messages = row.tags.map((_, i) => `message-${i}`);
10
+ const tags = new Map(messages.map((message, i) => [message, Math.max(0, ...row.tags[i])]));
11
+ const policy = createProcessedImageEligibility(messages, tags, {
12
+ watermark: row.watermark,
13
+ protectedCutoff: row.cutoff,
14
+ contextPercentage: row.percentage,
15
+ });
16
+ expect(policy.ageTags.get(messages[row.target]) ?? null).toBe(row.age);
17
+ expect(policy.mayStrip(messages[row.target])).toBe(row.eligible);
18
+ });
19
+ }
@@ -0,0 +1,34 @@
1
+ import { expect, test } from "bun:test";
2
+ import { recoveryReasoningPrefixes } from "./recovery-reasoning-prefix";
3
+
4
+ for (const key of ["content", "parts"] as const) {
5
+ test(`recovery reasoning ${key}: exact preceding messages and same-message parts`, () => {
6
+ const messages = [
7
+ { role: "user", [key]: [{ type: "text", text: "original" }] },
8
+ {
9
+ role: "assistant",
10
+ [key]: [
11
+ { type: "text", text: "before" },
12
+ { type: "thinking", thinkingSignature: "first" },
13
+ { type: "text", text: "between" },
14
+ { type: "redacted_thinking", data: "opaque" },
15
+ { type: "text", text: "after" },
16
+ ],
17
+ },
18
+ ];
19
+ const original = recoveryReasoningPrefixes(messages, key);
20
+ expect(original).toHaveLength(2);
21
+ const edited = structuredClone(messages);
22
+ edited[0]![key]![0]!.text = "changed";
23
+ expect(recoveryReasoningPrefixes(edited, key)).not.toEqual(original);
24
+ const parts = structuredClone(messages);
25
+ parts[1]![key]![2]!.text = "changed";
26
+ expect(recoveryReasoningPrefixes(parts, key)[0]).toBe(original[0]);
27
+ expect(recoveryReasoningPrefixes(parts, key)[1]).not.toBe(original[1]);
28
+ const suffix = structuredClone(messages);
29
+ suffix[1]![key]![4]!.text = "changed";
30
+ expect(recoveryReasoningPrefixes(suffix, key)).toEqual(original);
31
+ suffix[1]![key]!.splice(3, 1);
32
+ expect(recoveryReasoningPrefixes(suffix, key)).not.toEqual(original);
33
+ });
34
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Serialize each request prefix ending at a thinking/reasoning part, including
3
+ * earlier messages and earlier parts of that message. Comparing these snapshots
4
+ * detects edits to bytes authenticated by a kept signature, or missing blocks.
5
+ * Include reasoning without a visible signature too: a host may carry its
6
+ * provider signature in fields this helper does not interpret.
7
+ */
8
+ export function recoveryReasoningPrefixes(
9
+ messages: readonly unknown[],
10
+ partsKey: "parts" | "content",
11
+ ): string[] {
12
+ const prefixes: string[] = [];
13
+ for (let index = 0; index < messages.length; index++) {
14
+ const message = messages[index] as Record<string, unknown> | null;
15
+ const parts = message?.[partsKey];
16
+ if (!Array.isArray(parts)) continue;
17
+ for (let p = 0; p < parts.length; p++) {
18
+ const type = (parts[p] as { type?: string } | null)?.type;
19
+ if (
20
+ type !== "thinking" &&
21
+ type !== "reasoning" &&
22
+ type !== "redactedThinking" &&
23
+ type !== "redacted_thinking"
24
+ )
25
+ continue;
26
+ prefixes.push(
27
+ JSON.stringify([
28
+ ...messages.slice(0, index),
29
+ { ...message, [partsKey]: parts.slice(0, p + 1) },
30
+ ]),
31
+ );
32
+ }
33
+ }
34
+ return prefixes;
35
+ }
@@ -39,6 +39,22 @@ const scenario = `
39
39
  hold();
40
40
  writer.exec("COMMIT");
41
41
 
42
+ writer.exec("BEGIN IMMEDIATE");
43
+ now += 101;
44
+ writer.exec("ROLLBACK");
45
+
46
+ writer.exec("CREATE TABLE result(value)");
47
+ const statementTimes = [now, now + 101];
48
+ performance.now = () => statementTimes.shift() ?? now;
49
+ writer.prepare("INSERT INTO result VALUES (1)").run();
50
+ now += 101;
51
+
52
+ let clockReads = 0;
53
+ performance.now = () => { clockReads++; return now; };
54
+ writer.exec("BEGIN IMMEDIATE");
55
+ writer.exec("COMMIT");
56
+ if (clockReads !== 2) throw new Error("fast unscoped transaction clock reads=" + clockReads);
57
+
42
58
  logger.flushLogger();
43
59
  writer.close();
44
60
  holder.close();
@@ -106,6 +122,21 @@ describe("sqlite writer diagnostics", () => {
106
122
  expect(consoleOutput).not.toContain("sqlite writer");
107
123
  });
108
124
 
125
+ test("unscoped rollback names the host, pid and caller at the 100ms threshold", () => {
126
+ const rolledBack = logLines.find((line) => line.includes("outcome=rolled_back"));
127
+ expect(rolledBack).toContain("lane=background");
128
+ expect(rolledBack).toContain("hold_ms=101");
129
+ expect(rolledBack).toMatch(/pid=\d+ host=opencode/);
130
+ expect(rolledBack).toContain("caller=");
131
+ });
132
+
133
+ test("native autocommit time is labelled as including acquisition, not lock ownership", () => {
134
+ const statement = logLines.find((line) => line.includes("site=autocommit"));
135
+ expect(statement).toContain("elapsed_ms=101");
136
+ expect(statement).toContain("timing=statement_including_acquisition");
137
+ expect(statement).not.toContain("hold_ms=");
138
+ });
139
+
109
140
  test("a writer that waited for the lock reports the wait, not its short hold", () => {
110
141
  const waited = logLines.find((line) => line.includes("attempts=2"));
111
142
  if (!waited) throw new Error(`no retried acquisition logged:\n${logLines.join("\n")}`);