@cortexkit/opencode-magic-context 0.49.86 → 0.49.89

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 (182) hide show
  1. package/dist/{announcement-fnyxaahs.js → announcement-4ynkaf0d.js} +2 -2
  2. package/dist/auto-search-worker.js +13 -7
  3. package/dist/chunk-embedding-write-worker.js +7 -7
  4. package/dist/{compartment-chunk-embedding-ymc9mtwv.js → compartment-chunk-embedding-fey2bsyf.js} +3 -1
  5. package/dist/{conflict-warning-hook-a0wrnzch.js → conflict-warning-hook-kbq6ppjf.js} +2 -2
  6. package/dist/{context-xesm7rj3.js → context-grdg1k2k.js} +132 -52
  7. package/dist/{derive-budgets-90869322.js → derive-budgets-hzzq71rm.js} +2 -2
  8. package/dist/{embedding-backfill-v6sw58m8.js → embedding-backfill-qjkaee9s.js} +8 -8
  9. package/dist/{v2/embedding-cache-mgyr73ef.js → embedding-cache-zn4r1c31.js} +5 -1
  10. package/dist/embedding-worker.js +2 -2
  11. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +1 -0
  12. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  13. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/token-budget.d.ts +8 -3
  15. package/dist/features/magic-context/dreamer/token-budget.d.ts.map +1 -1
  16. package/dist/features/magic-context/memory/embedding-cache.d.ts +7 -0
  17. package/dist/features/magic-context/memory/embedding-cache.d.ts.map +1 -1
  18. package/dist/features/magic-context/search.d.ts +6 -0
  19. package/dist/features/magic-context/search.d.ts.map +1 -1
  20. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  21. package/dist/features/magic-context/tool-definition-tokens.d.ts +2 -0
  22. package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/auto-search-worker-probe.fixture.d.ts +2 -0
  25. package/dist/hooks/magic-context/auto-search-worker-probe.fixture.d.ts.map +1 -0
  26. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
  27. package/dist/hooks/magic-context/compartment-runner-recomp-carry.d.ts +4 -0
  28. package/dist/hooks/magic-context/compartment-runner-recomp-carry.d.ts.map +1 -0
  29. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts +8 -2
  30. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  31. package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
  32. package/dist/hooks/magic-context/emergency-fail-closed.d.ts +2 -0
  33. package/dist/hooks/magic-context/emergency-fail-closed.d.ts.map +1 -1
  34. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +3 -5
  35. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/send-session-notification.d.ts +11 -1
  37. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/transform.d.ts +1 -0
  39. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  40. package/dist/{index-s8ks5nz4.js → index-2pdgy88n.js} +5 -5
  41. package/dist/{index-7j2zv9nm.js → index-2qsca7h7.js} +47 -11
  42. package/dist/{index-1bqkqde0.js → index-39rzef89.js} +9 -7
  43. package/dist/{index-snbpdpa3.js → index-3pdknr07.js} +4 -4
  44. package/dist/{index-c5tmzym6.js → index-5df2fw5b.js} +108 -13
  45. package/dist/{index-7svecf3m.js → index-5pgyqgmx.js} +1 -1
  46. package/dist/{index-xrnhxkz7.js → index-60wnwcwz.js} +1 -1
  47. package/dist/{index-k50xhjw1.js → index-60x5d68t.js} +1 -1
  48. package/dist/{index-4ntnt8ee.js → index-61knrt52.js} +1 -1
  49. package/dist/{index-g6hfh4h4.js → index-6zewd2n5.js} +14 -8
  50. package/dist/{index-70cv85b0.js → index-78t37mcq.js} +2 -2
  51. package/dist/{index-stx8zd81.js → index-83qd3n7s.js} +2 -2
  52. package/dist/{index-nny4gm06.js → index-9d3qgwq0.js} +2 -2
  53. package/dist/{index-jjvbk92s.js → index-9emdjcb5.js} +1 -1
  54. package/dist/{index-05bm2ndp.js → index-chpzb6xy.js} +1 -1
  55. package/dist/{index-2kf73btc.js → index-cr483vx6.js} +1 -1
  56. package/dist/{index-d0rtbv0f.js → index-dk3hy2a2.js} +21 -14
  57. package/dist/{index-gxdc95cp.js → index-g0mb2kb4.js} +585 -82
  58. package/dist/{index-w6v4dw5f.js → index-h9hybzr5.js} +5 -5
  59. package/dist/{index-1pf5qrx4.js → index-jzfsnbmm.js} +3 -3
  60. package/dist/{index-jrj95cce.js → index-m6dnydf8.js} +9 -2
  61. package/dist/{index-xccywqdj.js → index-mrjat4eq.js} +77 -14
  62. package/dist/{index-022w6314.js → index-n1ty0vd3.js} +116 -512
  63. package/dist/{index-ttk3trse.js → index-q7msfgwz.js} +311 -111
  64. package/dist/{index-e32b3x4n.js → index-qfcjrnpe.js} +7 -6
  65. package/dist/{v2/server-4dhv7mqz.js → index-qjwpqvnf.js} +48 -1
  66. package/dist/{index-3dtzyred.js → index-r4y0dczp.js} +1 -1
  67. package/dist/{index-4w5rx7de.js → index-tt0vs4x5.js} +2 -2
  68. package/dist/{index-k0tb2z28.js → index-w51n3576.js} +2 -2
  69. package/dist/{index-25nktq8n.js → index-wmb2mcdw.js} +7 -7
  70. package/dist/{index-zmqx48vt.js → index-xsqw8kbd.js} +1 -1
  71. package/dist/{index-fzgyvsb1.js → index-y14pawe1.js} +3 -0
  72. package/dist/{index-798s7c8s.js → index-zxhev8ze.js} +2 -2
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +68 -59
  75. package/dist/{message-index-bounded-6fr624zf.js → message-index-bounded-r1qys471.js} +4 -4
  76. package/dist/migration-worker.js +5 -5
  77. package/dist/plugin/messages-transform.d.ts +3 -4
  78. package/dist/plugin/messages-transform.d.ts.map +1 -1
  79. package/dist/plugin/refusal-notice.d.ts +3 -0
  80. package/dist/plugin/refusal-notice.d.ts.map +1 -0
  81. package/dist/{project-embedding-registry-q80scexh.js → project-embedding-registry-m3fp1pa4.js} +7 -7
  82. package/dist/raw-ordinal-warmup-worker.js +4 -4
  83. package/dist/{read-session-chunk-6wedfths.js → read-session-chunk-xv9f0wgb.js} +3 -3
  84. package/dist/{recomp-orchestrator-7ecg8ryx.js → recomp-orchestrator-dgyb394j.js} +23 -23
  85. package/dist/{render-yqp7q79f.js → render-d014e603.js} +12 -12
  86. package/dist/{rpc-notifications-t9q0ynq7.js → rpc-notifications-ta2zsxpq.js} +1 -1
  87. package/dist/{search-bw22d7zc.js → search-9gceftb9.js} +18 -18
  88. package/dist/{search-archive-r4h96j2z.js → search-archive-gybn6q7s.js} +5 -5
  89. package/dist/{send-session-notification-7x518gew.js → send-session-notification-gzxz88vq.js} +1 -1
  90. package/dist/shared/assistant-message-extractor.d.ts +2 -0
  91. package/dist/shared/assistant-message-extractor.d.ts.map +1 -1
  92. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  93. package/dist/shared/recomp-outcome.d.ts +4 -0
  94. package/dist/shared/recomp-outcome.d.ts.map +1 -0
  95. package/dist/shared/rpc-notifications.d.ts +1 -1
  96. package/dist/shared/rpc-notifications.d.ts.map +1 -1
  97. package/dist/shared/storage-permissions.d.ts +16 -2
  98. package/dist/shared/storage-permissions.d.ts.map +1 -1
  99. package/dist/shared/user-facing-codes.d.ts +4 -1
  100. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  101. package/dist/{storage-memory-e6a7mb0k.js → storage-memory-hhrvfw0x.js} +2 -2
  102. package/dist/{storage-tags-y2mrb8e6.js → storage-tags-f1ftvjpw.js} +2 -2
  103. package/dist/{transform-postprocess-phase-t99yj9vt.js → transform-postprocess-phase-34k1zwsy.js} +24 -24
  104. package/dist/v2/auto-search-worker.js +13 -7
  105. package/dist/v2/chunk-embedding-write-worker.js +7 -7
  106. package/dist/v2/{compartment-chunk-embedding-x6qw6mjk.js → compartment-chunk-embedding-knt2468v.js} +3 -1
  107. package/dist/v2/{context-k8sx1nyy.js → context-8bzydxfy.js} +227 -70
  108. package/dist/v2/{derive-budgets-ecjy1aqh.js → derive-budgets-hr4qqrnv.js} +3 -3
  109. package/dist/v2/{embedding-backfill-k8kqnwfq.js → embedding-backfill-0ar1bm97.js} +8 -8
  110. package/dist/{embedding-cache-mgyr73ef.js → v2/embedding-cache-zn4r1c31.js} +5 -1
  111. package/dist/v2/embedding-worker.js +2 -2
  112. package/dist/v2/fold/native-replay.d.ts +3 -1
  113. package/dist/v2/fold/native-replay.d.ts.map +1 -1
  114. package/dist/v2/hidden-child-record.d.ts +1 -0
  115. package/dist/v2/hidden-child-record.d.ts.map +1 -1
  116. package/dist/v2/hidden-completion.d.ts.map +1 -1
  117. package/dist/v2/hooks/context.d.ts.map +1 -1
  118. package/dist/v2/{message-index-bounded-jqy7283g.js → message-index-bounded-b07r9cjv.js} +4 -4
  119. package/dist/v2/migration-worker.js +5 -5
  120. package/dist/v2/{project-embedding-registry-2jp1antr.js → project-embedding-registry-gx2waee8.js} +7 -7
  121. package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
  122. package/dist/v2/{read-session-chunk-n3nhfvd7.js → read-session-chunk-38wdy8nd.js} +3 -3
  123. package/dist/v2/{recomp-orchestrator-ssde9ft1.js → recomp-orchestrator-wq7gbkqa.js} +24 -24
  124. package/dist/v2/{render-fezgh7pa.js → render-2dan17xc.js} +12 -12
  125. package/dist/v2/{rpc-notifications-t9q0ynq7.js → rpc-notifications-ta2zsxpq.js} +1 -1
  126. package/dist/v2/{search-archive-zz1kza50.js → search-archive-89hdy0a2.js} +5 -5
  127. package/dist/v2/{search-m251amra.js → search-nyqykx7q.js} +17 -17
  128. package/dist/v2/{send-session-notification-p52rhjzy.js → send-session-notification-zazaxxpf.js} +1 -1
  129. package/dist/v2/{server-4wwwm2ya.js → server-09h2vyvs.js} +5 -5
  130. package/dist/v2/{server-r2es6zt7.js → server-0tv6kytx.js} +108 -13
  131. package/dist/v2/{server-rz4snd3x.js → server-1rrmxhd1.js} +1 -1
  132. package/dist/v2/{server-wdq85mxj.js → server-6250cxzs.js} +14 -8
  133. package/dist/v2/{server-xa8fefhw.js → server-96nm9vk4.js} +1 -1
  134. package/dist/v2/{server-jjvbk92s.js → server-9emdjcb5.js} +1 -1
  135. package/dist/v2/{server-ap81bk3c.js → server-9n2qgk29.js} +1 -1
  136. package/dist/v2/{server-ps6rz88g.js → server-a85j3kam.js} +2 -2
  137. package/dist/v2/{server-y31y6gws.js → server-add0j5n3.js} +9 -7
  138. package/dist/v2/{server-97w51d8n.js → server-b0a9h3ds.js} +3 -3
  139. package/dist/v2/{server-2k8tkbhz.js → server-c7awk5s2.js} +10 -4
  140. package/dist/v2/{server-hn8b7sfe.js → server-dgjqvpgd.js} +5 -5
  141. package/dist/v2/{server-fsw8kbng.js → server-dtcwkdqj.js} +314 -114
  142. package/dist/v2/{server-mbkwcwgw.js → server-f7tzvmzs.js} +2 -2
  143. package/dist/v2/{server-n5zr7190.js → server-fb5hvvfc.js} +77 -14
  144. package/dist/v2/{server-w7mpvkpj.js → server-fn4ky6mn.js} +1 -1
  145. package/dist/v2/{server-3p6b0qya.js → server-gqkdfdvw.js} +1 -1
  146. package/dist/v2/{server-cwtehwbb.js → server-j4jjtdc5.js} +1 -1
  147. package/dist/v2/{server-b93f0bqh.js → server-pjk9spbf.js} +1 -1
  148. package/dist/v2/{server-s15knz0w.js → server-pmws7we9.js} +1 -1
  149. package/dist/{index-4dhv7mqz.js → v2/server-qjwpqvnf.js} +48 -1
  150. package/dist/v2/{server-a2f1bhyj.js → server-stjy5dxv.js} +9 -2
  151. package/dist/v2/{server-ssg29wjg.js → server-ta4h0fch.js} +21 -14
  152. package/dist/v2/{server-e2k9mt86.js → server-tj65pgvg.js} +1 -1
  153. package/dist/v2/{server-brgandk4.js → server-vy0beygw.js} +2 -2
  154. package/dist/v2/{server-fzgyvsb1.js → server-y14pawe1.js} +3 -0
  155. package/dist/v2/{server-8pdfmc27.js → server-y17r5ryz.js} +4 -4
  156. package/dist/v2/{server-sxfbjdye.js → server-yx0nyj1q.js} +2 -2
  157. package/dist/v2/server.js +6 -6
  158. package/dist/v2/{storage-memory-e6a7mb0k.js → storage-memory-hhrvfw0x.js} +2 -2
  159. package/dist/v2/{storage-tags-xq81zgt2.js → storage-tags-pmw33chf.js} +2 -2
  160. package/dist/v2/{v2-archive-reader-e2w39c3p.js → v2-archive-reader-gh1jghf7.js} +1 -1
  161. package/dist/v2/{wrapup-orchestrator-eg5b1p89.js → wrapup-orchestrator-2h7ayss9.js} +24 -24
  162. package/dist/{v2-archive-reader-8dsngf2j.js → v2-archive-reader-8158kyfd.js} +1 -1
  163. package/dist/{wrapup-orchestrator-nmk6yf7f.js → wrapup-orchestrator-ct59br0c.js} +24 -24
  164. package/package.json +1 -1
  165. package/src/shared/assistant-message-extractor.test.ts +22 -0
  166. package/src/shared/assistant-message-extractor.ts +13 -0
  167. package/src/shared/model-suggestion-retry.test.ts +43 -12
  168. package/src/shared/prompt-async-transport.test.ts +275 -8
  169. package/src/shared/prompt-async-transport.ts +41 -2
  170. package/src/shared/recomp-outcome.ts +8 -0
  171. package/src/shared/reusable-worker.fixture.ts +15 -3
  172. package/src/shared/reusable-worker.test.ts +20 -10
  173. package/src/shared/rpc-notifications.ts +4 -1
  174. package/src/shared/sqlite-foreground-wait.test.ts +2 -2
  175. package/src/shared/startup-maintenance-policy.test.ts +4 -2
  176. package/src/shared/storage-permissions-startup.test.ts +296 -6
  177. package/src/shared/storage-permissions.ts +143 -18
  178. package/src/shared/user-facing-codes.ts +5 -2
  179. package/src/tui/dialogs/status-dialog.tsx +3 -0
  180. package/src/tui/slots/sidebar-content.tsx +6 -2
  181. package/src/tui-compiled/dialogs/status-dialog.tsx +12 -0
  182. package/src/tui-compiled/slots/sidebar-content.tsx +7 -2
@@ -19,6 +19,7 @@ import {
19
19
  readdirSync,
20
20
  readlinkSync,
21
21
  readSync,
22
+ realpathSync,
22
23
  renameSync,
23
24
  rmdirSync,
24
25
  rmSync,
@@ -28,6 +29,7 @@ import {
28
29
  } from "node:fs";
29
30
  import type { FileHandle } from "node:fs/promises";
30
31
  import { open as openAsync, writeFile as writeFileAsync } from "node:fs/promises";
32
+ import { homedir } from "node:os";
31
33
  import { basename, dirname, join, resolve } from "node:path";
32
34
  import { isPidAlive } from "./rpc-utils";
33
35
 
@@ -38,10 +40,46 @@ const STORAGE_PERMISSIONS_MARKER_BYTES = Buffer.from(`${STORAGE_PERMISSIONS_POLI
38
40
  const STORAGE_PERMISSIONS_MARKER_MAX_AGE_MS = 24 * 60 * 60_000;
39
41
  const LEGACY_FENCE_TEMP_MIN_AGE_MS = 10 * 60_000;
40
42
 
43
+ /** Top-level names that Magic Context creates in its data folder. */
44
+ export const MAGIC_CONTEXT_STORAGE_ENTRIES: readonly (string | RegExp)[] = [
45
+ "context.db",
46
+ "context.db-wal",
47
+ "context.db-shm",
48
+ "context.db-journal",
49
+ "store.db", // The 0.49 Magic Context module's companion database.
50
+ "store.db-wal",
51
+ "store.db-shm",
52
+ "store.db-journal",
53
+ STORAGE_PERMISSIONS_MARKER,
54
+ "models",
55
+ "logs",
56
+ "backups",
57
+ "config-backups",
58
+ "lkg-recovery-fences",
59
+ "rpc",
60
+ "project-identities",
61
+ "heap-snapshots",
62
+ "host-profiler",
63
+ "pi-served-array-digests",
64
+ "pi-served-array-bodies",
65
+ "pi-served-tag-numbers",
66
+ "window-reports.jsonl",
67
+ "window-reports.jsonl.1",
68
+ // Atomic storage writes add .<pid>.<12 hex digits>.tmp to these root files.
69
+ /^(?:last_announced_version|last-update-check\.json|pending-plugin-update\.json|model-context-limits-(?:opencode|opencode2)\.json)(?:\.[1-9]\d*\.[a-f0-9]{12}\.tmp)?$/,
70
+ /^identity-merge-backup-[A-Za-z0-9]{6}$/,
71
+ // Session migration snapshot and database-repair copies/staging bundles.
72
+ /^context\.db\.bak-\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z$/,
73
+ /^context\.db\.corrupt-(?:backup|original)-\d{8}T\d{9}Z(?:-[1-9]\d{0,3})?(?:-wal|-shm)?$/,
74
+ /^context\.db\.recovering-\d{8}T\d{9}Z-[1-9]\d*(?:-[1-9]\d{0,3})?(?:\.(?:count-source|recover-source|(?:fresh\.)?db)(?:-wal|-shm)?|\.sql)$/,
75
+ ];
76
+
41
77
  /**
42
- * Storage roots that this process checked with tightenStorageTreeSync. Only a
43
- * root has a marker. Each database open checks its root, so a process that
44
- * writes storage files knows its root.
78
+ * Storage roots and their configured aliases. When a writer finds a loose
79
+ * mode in the tree, it deletes the marker file that certifies the tree as
80
+ * private, looking upward from the path it wrote. That search must stop at
81
+ * the storage root, whether the writer reached it by its real path or
82
+ * through a link.
45
83
  */
46
84
  const storagePermissionRoots = new Set<string>();
47
85
 
@@ -299,15 +337,97 @@ function readStoragePermissionCertificate(marker: string): Stats | undefined {
299
337
  }
300
338
  }
301
339
 
302
- /** Tighten existing entries during storage startup; symlinks are never followed. */
340
+ type LinkedRootSkip = "filesystem-root" | "home-folder" | "mount-point" | number;
341
+
342
+ function inspectLinkedStorageRoot(
343
+ root: string,
344
+ rootStat: Stats,
345
+ ): { skipped: LinkedRootSkip } | { entries: string[] } {
346
+ const parent = dirname(root);
347
+ if (root === parent) return { skipped: "filesystem-root" };
348
+ try {
349
+ if (root === realpathSync(homedir())) return { skipped: "home-folder" };
350
+ } catch (error) {
351
+ // A missing home cannot be the existing target. Other errors prevent the safety check.
352
+ if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
353
+ }
354
+ if (lstatSync(parent).dev !== rootStat.dev) return { skipped: "mount-point" };
355
+ const entries = readdirSync(root);
356
+ const foreignEntries = entries.filter(
357
+ (name) =>
358
+ name !== ".DS_Store" &&
359
+ !MAGIC_CONTEXT_STORAGE_ENTRIES.some((entry) =>
360
+ typeof entry === "string" ? entry === name : entry.test(name),
361
+ ),
362
+ ).length;
363
+ return foreignEntries === 0 ? { entries } : { skipped: foreignEntries };
364
+ }
365
+
366
+ type StoragePermissionCheck = {
367
+ tightened: number;
368
+ failures: number;
369
+ rootLink?:
370
+ | { path: string; target: string; skipped?: LinkedRootSkip }
371
+ | { path: string; failure: string; nonDirectoryTarget?: string };
372
+ };
373
+
374
+ /** Tighten existing entries during startup. Follow a linked storage root, but no links inside it. */
303
375
  export function tightenStorageTreeSync(
304
376
  directory: string,
305
377
  dbPath = join(directory, "context.db"),
306
- ): { tightened: number; failures: number } {
378
+ ): StoragePermissionCheck {
307
379
  if (process.platform === "win32") {
308
380
  return { tightened: 0, failures: 0 };
309
381
  }
310
- const root = resolve(directory);
382
+ const enforce = shouldEnforcePrivateStoragePermissions();
383
+ const startupPath = resolve(directory);
384
+ let root = startupPath;
385
+ let rootStat: Stats | undefined;
386
+ let rootLink: StoragePermissionCheck["rootLink"];
387
+ let linkedEntries: string[] | undefined;
388
+ try {
389
+ rootStat = lstatSync(root);
390
+ } catch {
391
+ if (enforce) return { tightened: 0, failures: 1 };
392
+ }
393
+ if (rootStat?.isSymbolicLink()) {
394
+ try {
395
+ root = realpathSync(startupPath);
396
+ rootStat = lstatSync(root);
397
+ if (rootStat.isDirectory() && enforce) {
398
+ const eligibility = inspectLinkedStorageRoot(root, rootStat);
399
+ if ("skipped" in eligibility) {
400
+ return {
401
+ tightened: 0,
402
+ failures: 0,
403
+ rootLink: { path: startupPath, target: root, skipped: eligibility.skipped },
404
+ };
405
+ }
406
+ linkedEntries = eligibility.entries;
407
+ }
408
+ } catch (error) {
409
+ if (!enforce) return { tightened: 0, failures: 0 };
410
+ const failure = (error as NodeJS.ErrnoException).code ?? String(error);
411
+ return { tightened: 0, failures: 1, rootLink: { path: startupPath, failure } };
412
+ }
413
+ if (!rootStat.isDirectory()) {
414
+ if (!enforce) return { tightened: 0, failures: 0 };
415
+ return {
416
+ tightened: 0,
417
+ failures: 1,
418
+ rootLink: {
419
+ path: startupPath,
420
+ failure: "not a directory",
421
+ nonDirectoryTarget: root,
422
+ },
423
+ };
424
+ }
425
+ rootLink = { path: startupPath, target: root };
426
+ // Check the DB and sidecars in the same directory as the walk and marker,
427
+ // even if the configured link is redirected during the check.
428
+ dbPath = join(root, basename(dbPath));
429
+ storagePermissionRoots.add(startupPath);
430
+ }
311
431
  const marker = join(root, STORAGE_PERMISSIONS_MARKER);
312
432
  let tightened = 0;
313
433
  let failures = 0;
@@ -320,18 +440,12 @@ export function tightenStorageTreeSync(
320
440
  return false;
321
441
  }
322
442
  };
323
- if (!shouldEnforcePrivateStoragePermissions()) {
443
+ if (!enforce) {
324
444
  storagePermissionRoots.add(root);
325
445
  if (!removeMarker()) failures++;
326
- return { tightened, failures };
327
- }
328
- let rootStat: Stats;
329
- try {
330
- rootStat = lstatSync(root);
331
- if (!rootStat.isDirectory()) return { tightened, failures: 1 };
332
- } catch {
333
- return { tightened, failures: 1 };
446
+ return { tightened, failures, ...(rootLink && { rootLink }) };
334
447
  }
448
+ if (!rootStat?.isDirectory()) return { tightened, failures: 1 };
335
449
  storagePermissionRoots.add(root);
336
450
  let certificate: Stats | undefined;
337
451
  let discardMarker = false;
@@ -413,12 +527,23 @@ export function tightenStorageTreeSync(
413
527
  if (!recursive || !stat.isDirectory()) return;
414
528
  let entries: string[];
415
529
  try {
416
- entries = readdirSync(entryPath);
530
+ // Do not walk any root entry that was not included in the eligibility check.
531
+ entries = (entryPath === root ? linkedEntries : undefined) ?? readdirSync(entryPath);
417
532
  } catch {
418
533
  failures++;
419
534
  return;
420
535
  }
421
- for (const entry of entries) visit(join(entryPath, entry));
536
+ for (const entry of entries) {
537
+ // The snapshot may still list the marker file this check just removed.
538
+ if (
539
+ entryPath === root &&
540
+ linkedEntries &&
541
+ markerRemoved &&
542
+ entry === STORAGE_PERMISSIONS_MARKER
543
+ )
544
+ continue;
545
+ visit(join(entryPath, entry));
546
+ }
422
547
  };
423
548
  if (certificate) {
424
549
  visit(root, false, false, rootStat);
@@ -469,5 +594,5 @@ export function tightenStorageTreeSync(
469
594
  }
470
595
  }
471
596
  }
472
- return { tightened, failures };
597
+ return { tightened, failures, ...(rootLink && { rootLink }) };
473
598
  }
@@ -299,10 +299,13 @@ export type UserFacingTextStyle = "markdown" | "plain";
299
299
  export function renderUserFacingFailure(
300
300
  key: UserFacingFailureKey,
301
301
  style: UserFacingTextStyle = "markdown",
302
+ overrides?: { sentence?: string; action?: string },
302
303
  ): string {
303
304
  const failure = USER_FACING_FAILURES[key];
304
- const action = style === "plain" ? failure.action.replaceAll("`", "") : failure.action;
305
- return `${failure.sentence} ${action} (${failure.code})`;
305
+ const sentence = overrides?.sentence ?? failure.sentence;
306
+ const action = overrides?.action ?? failure.action;
307
+ const styledAction = style === "plain" ? action.replaceAll("`", "") : action;
308
+ return `${sentence}${styledAction ? ` ${styledAction}` : ""} (${failure.code})`;
306
309
  }
307
310
 
308
311
  export function userFacingFailureCode(key: UserFacingFailureKey): string {
@@ -12,6 +12,7 @@
12
12
  import { createMemo, createSignal, onCleanup } from "solid-js"
13
13
  import type { TuiPluginApi, TuiThemeCurrent } from "@opencode-ai/plugin/tui"
14
14
  import packageJson from "../../../package.json"
15
+ import { pausedRecompReason } from "../../shared/recomp-outcome"
15
16
  import {
16
17
  buildStatusViewFor,
17
18
  distributeBarWidths,
@@ -229,6 +230,8 @@ export const StatusDialog = (props: { api: TuiPluginApi; status: StatusDetailRes
229
230
  if (p.phase === "migration") return <R t={t()} l="Status" v={p.note ?? "Migrating memories ⟳"} fg={t().warning} />
230
231
  if (p.phase === "done") return <R t={t()} l="Status" v={`✓ ${verb} complete`} fg={t().accent} />
231
232
  if (p.phase === "skipped") return <R t={t()} l="Status" v={p.message ?? `${verb} stopped early`} fg={t().textMuted} />
233
+ const paused = pausedRecompReason(p.message)
234
+ if (paused !== null) return <R t={t()} l="Status" v={`${verb} paused: ${paused}`} fg={t().warning} />
232
235
  return <R t={t()} l="Status" v={`✗ ${verb} failed${p.message ? `: ${p.message}` : ""}`} fg={t().error} />
233
236
  })()}
234
237
  </box>
@@ -6,6 +6,7 @@ import { badgeTextColor } from '../badge-contrast';
6
6
  import { loadSidebarSnapshot, type SidebarSnapshot } from "../data/context-db"
7
7
  import { directoryForSession } from "../data/session-directory"
8
8
  import { formatThresholdPercent } from "../../shared/format-threshold"
9
+ import { pausedRecompReason } from "../../shared/recomp-outcome"
9
10
  import { renderUserFacingFailure } from "../../shared/user-facing-codes"
10
11
  import { compactionOffSidebarRows, nativeCompactionContextLabel } from "../compaction-off"
11
12
  import {
@@ -416,6 +417,7 @@ const RecompProgressSection = (props: {
416
417
  : props.progress.kind === "wrapup"
417
418
  ? "wrapping ⟳"
418
419
  : "comparting ⟳"
420
+ const paused = createMemo(() => pausedRecompReason(props.progress.message))
419
421
  const label = createMemo(() => {
420
422
  switch (props.progress.phase) {
421
423
  case "recomp":
@@ -436,7 +438,9 @@ const RecompProgressSection = (props: {
436
438
  // "retry shortly" (wrong for a partial stall).
437
439
  return { text: "stopped", color: props.theme.textMuted }
438
440
  case "failed":
439
- return { text: `✗ ${verb()} failed`, color: props.theme.error }
441
+ return paused() === null
442
+ ? { text: `✗ ${verb()} failed`, color: props.theme.error }
443
+ : { text: `${verb()} paused`, color: props.theme.warning }
440
444
  }
441
445
  })
442
446
 
@@ -480,7 +484,7 @@ const RecompProgressSection = (props: {
480
484
  {/* Terminal reason (failed/skipped) — kept visible so the user sees
481
485
  WHY (a failure, or the transient "retry shortly" skip cause). */}
482
486
  {(phase() === "failed" || phase() === "skipped") && props.progress.message && (
483
- <text fg={props.theme.textMuted}>{props.progress.message}</text>
487
+ <text fg={props.theme.textMuted}>{paused() ?? props.progress.message}</text>
484
488
  )}
485
489
  </>
486
490
  )
@@ -22,6 +22,7 @@ import { createElement as _$createElement } from "opentui:runtime-module:%40open
22
22
  */
23
23
  import { createMemo, createSignal, onCleanup } from "opentui:runtime-module:solid-js";
24
24
  import packageJson from "../../../package.json";
25
+ import { pausedRecompReason } from "../../shared/recomp-outcome";
25
26
  import { buildStatusViewFor, distributeBarWidths, statusColumnsFor } from "../../shared/status-view";
26
27
  import { RUST_MODE_HOST_PATHS_LINE } from "../../shared/rust-mode-status";
27
28
  const R = props => (() => {
@@ -413,6 +414,17 @@ export const StatusDialog = props => {
413
414
  return t().textMuted;
414
415
  }
415
416
  });
417
+ const paused = pausedRecompReason(p.message);
418
+ if (paused !== null) return _$createComponent(R, {
419
+ get t() {
420
+ return t();
421
+ },
422
+ l: "Status",
423
+ v: `${verb} paused: ${paused}`,
424
+ get fg() {
425
+ return t().warning;
426
+ }
427
+ });
416
428
  return _$createComponent(R, {
417
429
  get t() {
418
430
  return t();
@@ -13,6 +13,7 @@ import { badgeTextColor } from "../badge-contrast";
13
13
  import { loadSidebarSnapshot } from "../data/context-db";
14
14
  import { directoryForSession } from "../data/session-directory";
15
15
  import { formatThresholdPercent } from "../../shared/format-threshold";
16
+ import { pausedRecompReason } from "../../shared/recomp-outcome";
16
17
  import { renderUserFacingFailure } from "../../shared/user-facing-codes";
17
18
  import { compactionOffSidebarRows, nativeCompactionContextLabel } from "../compaction-off";
18
19
  import { computeEffectiveOrder, DEFAULT_SLOT_ORDER, PLUGIN_KEY, queueTuiPreferenceUpdate, readTuiPreferencesFile, readTuiPreferencesFileSync, resolveMagicContextPrefs, watchTuiPreferences } from "../../shared/tui-preferences";
@@ -406,6 +407,7 @@ const RecompProgressSection = props => {
406
407
  // run, so a plain /ctx-recomp never renders as an "Upgrade" (dogfood 2026-06-04).
407
408
  const verb = () => props.progress.kind === "upgrade" ? "Upgrade" : props.progress.kind === "embed" ? "Embed" : props.progress.kind === "wrapup" ? "Wrapup" : "Recomp";
408
409
  const activeText = () => props.progress.kind === "upgrade" ? "upgrading ⟳" : props.progress.kind === "embed" ? "embedding ⟳" : props.progress.kind === "wrapup" ? "wrapping ⟳" : "comparting ⟳";
410
+ const paused = createMemo(() => pausedRecompReason(props.progress.message));
409
411
  const label = createMemo(() => {
410
412
  switch (props.progress.phase) {
411
413
  case "recomp":
@@ -435,9 +437,12 @@ const RecompProgressSection = props => {
435
437
  color: props.theme.textMuted
436
438
  };
437
439
  case "failed":
438
- return {
440
+ return paused() === null ? {
439
441
  text: `✗ ${verb()} failed`,
440
442
  color: props.theme.error
443
+ } : {
444
+ text: `${verb()} paused`,
445
+ color: props.theme.warning
441
446
  };
442
447
  }
443
448
  });
@@ -515,7 +520,7 @@ const RecompProgressSection = props => {
515
520
  dim: true
516
521
  })), _$memo(() => _$memo(() => !!((phase() === "failed" || phase() === "skipped") && props.progress.message))() && (() => {
517
522
  var _el$24 = _$createElement("text");
518
- _$insert(_el$24, () => props.progress.message);
523
+ _$insert(_el$24, () => paused() ?? props.progress.message);
519
524
  _$effect(_$p => _$setProp(_el$24, "fg", props.theme.textMuted, _$p));
520
525
  return _el$24;
521
526
  })())];