@cortexkit/opencode-magic-context 0.41.4 → 0.42.1

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 (358) hide show
  1. package/README.md +21 -3
  2. package/dist/agents/hidden-agent-registrations.d.ts +1 -3
  3. package/dist/agents/hidden-agent-registrations.d.ts.map +1 -1
  4. package/dist/agents/magic-context-prompt.d.ts +1 -1
  5. package/dist/agents/magic-context-prompt.d.ts.map +1 -1
  6. package/dist/agents/permissions.d.ts +1 -22
  7. package/dist/agents/permissions.d.ts.map +1 -1
  8. package/dist/config/agent-disable.d.ts +0 -5
  9. package/dist/config/agent-disable.d.ts.map +1 -1
  10. package/dist/config/index.d.ts +5 -0
  11. package/dist/config/index.d.ts.map +1 -1
  12. package/dist/config/migrate-config-location.d.ts.map +1 -1
  13. package/dist/config/project-security.d.ts +20 -2
  14. package/dist/config/project-security.d.ts.map +1 -1
  15. package/dist/config/removed-agent-config.d.ts +8 -0
  16. package/dist/config/removed-agent-config.d.ts.map +1 -0
  17. package/dist/config/schema/magic-context.d.ts +43 -201
  18. package/dist/config/schema/magic-context.d.ts.map +1 -1
  19. package/dist/{conflict-warning-hook-ejkc9sjn.js → conflict-warning-hook-6p3xqeac.js} +3 -3
  20. package/dist/{derive-budgets-bc366cz8.js → derive-budgets-s2pgnnm4.js} +1 -1
  21. package/dist/features/builtin-commands/commands.d.ts +0 -4
  22. package/dist/features/builtin-commands/commands.d.ts.map +1 -1
  23. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  24. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +15 -4
  25. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  26. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
  27. package/dist/features/magic-context/context-authority.d.ts +31 -4
  28. package/dist/features/magic-context/context-authority.d.ts.map +1 -1
  29. package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
  30. package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
  31. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  32. package/dist/features/magic-context/dreamer/open-opencode-db.d.ts.map +1 -1
  33. package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
  34. package/dist/features/magic-context/dreamer/retrospective-orphan-sweep.d.ts +19 -9
  35. package/dist/features/magic-context/dreamer/retrospective-orphan-sweep.d.ts.map +1 -1
  36. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
  37. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  38. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +4 -0
  39. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  40. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  41. package/dist/features/magic-context/fail-closed-block.d.ts.map +1 -1
  42. package/dist/features/magic-context/git-commits/sweep-coordinator.d.ts.map +1 -1
  43. package/dist/features/magic-context/index.d.ts +0 -1
  44. package/dist/features/magic-context/index.d.ts.map +1 -1
  45. package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
  46. package/dist/features/magic-context/memory/embedding-local.d.ts +13 -0
  47. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  48. package/dist/features/magic-context/memory/embedding-model-match.d.ts +41 -0
  49. package/dist/features/magic-context/memory/embedding-model-match.d.ts.map +1 -0
  50. package/dist/features/magic-context/memory/embedding-openai.d.ts +7 -20
  51. package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
  52. package/dist/features/magic-context/memory/embedding-provider.d.ts +2 -2
  53. package/dist/features/magic-context/memory/embedding-provider.d.ts.map +1 -1
  54. package/dist/features/magic-context/memory/embedding-synapse.d.ts +48 -14
  55. package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
  56. package/dist/features/magic-context/memory/embedding.d.ts +1 -1
  57. package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
  58. package/dist/features/magic-context/memory/memory-migration.d.ts.map +1 -1
  59. package/dist/features/magic-context/memory/project-identity.d.ts +1 -0
  60. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  61. package/dist/features/magic-context/memory/promotion.d.ts +7 -1
  62. package/dist/features/magic-context/memory/promotion.d.ts.map +1 -1
  63. package/dist/features/magic-context/merged-reasoning-decisions.d.ts +6 -0
  64. package/dist/features/magic-context/merged-reasoning-decisions.d.ts.map +1 -0
  65. package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -1
  66. package/dist/features/magic-context/message-index-async.d.ts +12 -0
  67. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  68. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  69. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  70. package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
  71. package/dist/features/magic-context/mural/render-trigger.d.ts +6 -0
  72. package/dist/features/magic-context/mural/render-trigger.d.ts.map +1 -1
  73. package/dist/features/magic-context/no-content-compartment.d.ts +12 -0
  74. package/dist/features/magic-context/no-content-compartment.d.ts.map +1 -0
  75. package/dist/features/magic-context/pi-content-decisions.d.ts +9 -0
  76. package/dist/features/magic-context/pi-content-decisions.d.ts.map +1 -0
  77. package/dist/features/magic-context/project-docs-hash.d.ts +4 -0
  78. package/dist/features/magic-context/project-docs-hash.d.ts.map +1 -1
  79. package/dist/features/magic-context/project-embedding-registry.d.ts +13 -4
  80. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  81. package/dist/features/magic-context/protection-window.d.ts +79 -0
  82. package/dist/features/magic-context/protection-window.d.ts.map +1 -0
  83. package/dist/features/magic-context/search.d.ts.map +1 -1
  84. package/dist/features/magic-context/session-project-backfill.d.ts.map +1 -1
  85. package/dist/features/magic-context/shadow-backfill-state.d.ts +26 -0
  86. package/dist/features/magic-context/shadow-backfill-state.d.ts.map +1 -0
  87. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  88. package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts +4 -0
  89. package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts.map +1 -1
  90. package/dist/features/magic-context/smart-notes/storage.d.ts.map +1 -1
  91. package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
  92. package/dist/features/magic-context/storage-db.d.ts +1 -1
  93. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  94. package/dist/features/magic-context/storage-embedding-measurements.d.ts +2 -2
  95. package/dist/features/magic-context/storage-embedding-measurements.d.ts.map +1 -1
  96. package/dist/features/magic-context/storage-historian-runs.d.ts +4 -0
  97. package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -1
  98. package/dist/features/magic-context/storage-memory-mutation-log.d.ts +1 -0
  99. package/dist/features/magic-context/storage-memory-mutation-log.d.ts.map +1 -1
  100. package/dist/features/magic-context/storage-meta-persisted.d.ts +79 -13
  101. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  102. package/dist/features/magic-context/storage-meta.d.ts +1 -1
  103. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  104. package/dist/features/magic-context/storage-native-replay.d.ts +29 -0
  105. package/dist/features/magic-context/storage-native-replay.d.ts.map +1 -0
  106. package/dist/features/magic-context/storage-notes.d.ts +6 -0
  107. package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
  108. package/dist/features/magic-context/storage-replay-document.d.ts +33 -0
  109. package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -0
  110. package/dist/features/magic-context/storage-subagent-invocations.d.ts +1 -1
  111. package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -1
  112. package/dist/features/magic-context/storage-tags.d.ts +19 -11
  113. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  114. package/dist/features/magic-context/storage.d.ts +3 -3
  115. package/dist/features/magic-context/storage.d.ts.map +1 -1
  116. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
  117. package/dist/features/magic-context/tagger.d.ts +13 -0
  118. package/dist/features/magic-context/tagger.d.ts.map +1 -1
  119. package/dist/features/magic-context/tool-owner-backfill.d.ts.map +1 -1
  120. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
  121. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
  122. package/dist/features/magic-context/workspaces.d.ts.map +1 -1
  123. package/dist/hooks/magic-context/apply-operations.d.ts +11 -5
  124. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  125. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  126. package/dist/hooks/magic-context/cache-busting-signals.d.ts +9 -1
  127. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
  128. package/dist/hooks/magic-context/caveman-cleanup.d.ts +1 -1
  129. package/dist/hooks/magic-context/caveman-cleanup.d.ts.map +1 -1
  130. package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
  131. package/dist/hooks/magic-context/child-session-spawn.d.ts +3 -3
  132. package/dist/hooks/magic-context/child-session-spawn.d.ts.map +1 -1
  133. package/dist/hooks/magic-context/command-handler.d.ts +1 -10
  134. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  135. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
  136. package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts +10 -21
  137. package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts.map +1 -1
  138. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  139. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
  140. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  141. package/dist/hooks/magic-context/compartment-runner-validation.d.ts +1 -1
  142. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  143. package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts +26 -2
  144. package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts.map +1 -1
  145. package/dist/hooks/magic-context/decay-render.d.ts.map +1 -1
  146. package/dist/hooks/magic-context/dropped-input-guard.d.ts +9 -0
  147. package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -0
  148. package/dist/hooks/magic-context/embed-session-state.d.ts +1 -1
  149. package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -1
  150. package/dist/hooks/magic-context/emergency-drop.d.ts +6 -1
  151. package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
  152. package/dist/hooks/magic-context/event-handler.d.ts +0 -1
  153. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  154. package/dist/hooks/magic-context/event-payloads.d.ts +7 -6
  155. package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -1
  156. package/dist/hooks/magic-context/event-resolvers.d.ts +1 -1
  157. package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
  158. package/dist/hooks/magic-context/execute-status.d.ts +3 -1
  159. package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
  160. package/dist/hooks/magic-context/format-embed-failure.d.ts +2 -1
  161. package/dist/hooks/magic-context/format-embed-failure.d.ts.map +1 -1
  162. package/dist/hooks/magic-context/format-embed-status.d.ts.map +1 -1
  163. package/dist/hooks/magic-context/heuristic-cleanup.d.ts +7 -1
  164. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
  165. package/dist/hooks/magic-context/hook-handlers.d.ts +3 -1
  166. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  167. package/dist/hooks/magic-context/hook.d.ts +13 -4
  168. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  169. package/dist/hooks/magic-context/inject-compartments.d.ts +14 -1
  170. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  171. package/dist/hooks/magic-context/live-session-state.d.ts +1 -1
  172. package/dist/hooks/magic-context/lkg-slot.d.ts +34 -0
  173. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  174. package/dist/hooks/magic-context/maintenance-authority.d.ts +2 -2
  175. package/dist/hooks/magic-context/maintenance-authority.d.ts.map +1 -1
  176. package/dist/hooks/magic-context/module-state-sync-timing.d.ts +21 -0
  177. package/dist/hooks/magic-context/module-state-sync-timing.d.ts.map +1 -0
  178. package/dist/hooks/magic-context/module-state-sync.d.ts +21 -7
  179. package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
  180. package/dist/hooks/magic-context/module-transport.d.ts +12 -0
  181. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  182. package/dist/hooks/magic-context/module-wire.d.ts +8 -0
  183. package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
  184. package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
  185. package/dist/hooks/magic-context/persist-filtered-noise.d.ts +5 -0
  186. package/dist/hooks/magic-context/persist-filtered-noise.d.ts.map +1 -0
  187. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +6 -0
  188. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  189. package/dist/hooks/magic-context/read-session-chunk.d.ts +18 -18
  190. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  191. package/dist/hooks/magic-context/read-session-db.d.ts +22 -12
  192. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  193. package/dist/hooks/magic-context/read-session-formatting.d.ts +8 -0
  194. package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
  195. package/dist/hooks/magic-context/read-session-raw.d.ts +10 -1
  196. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  197. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  198. package/dist/hooks/magic-context/reference-retrieval.d.ts.map +1 -1
  199. package/dist/hooks/magic-context/rust-mode-transform.d.ts +74 -9
  200. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  201. package/dist/hooks/magic-context/send-session-notification.d.ts +11 -10
  202. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  203. package/dist/hooks/magic-context/strip-content.d.ts +7 -0
  204. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  205. package/dist/hooks/magic-context/supersession-reclaim.d.ts +13 -0
  206. package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -1
  207. package/dist/hooks/magic-context/system-prompt-hash.d.ts +2 -3
  208. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  209. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +8 -3
  210. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
  211. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  212. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  213. package/dist/hooks/magic-context/transform-context-state.d.ts +7 -1
  214. package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
  215. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +11 -4
  216. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  217. package/dist/hooks/magic-context/transform.d.ts +7 -2
  218. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  219. package/dist/hooks/magic-context/upgrade-reminder.d.ts +7 -9
  220. package/dist/hooks/magic-context/upgrade-reminder.d.ts.map +1 -1
  221. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  222. package/dist/index-1974jvn3.js +783 -0
  223. package/dist/{index-0y2mcg5y.js → index-1q9kay7n.js} +18717 -16197
  224. package/dist/{index-4avmwfp5.js → index-36wd1d6k.js} +6 -29
  225. package/dist/{index-fz104x1j.js → index-jmtjh2d3.js} +3 -3
  226. package/dist/{index-q264erdp.js → index-nqgjwfzn.js} +70 -38
  227. package/dist/{index-mjv9je4e.js → index-xdtge3y2.js} +45 -7
  228. package/dist/index.d.ts.map +1 -1
  229. package/dist/index.js +6457 -5190
  230. package/dist/plugin/conflict-warning-hook.d.ts +5 -6
  231. package/dist/plugin/conflict-warning-hook.d.ts.map +1 -1
  232. package/dist/plugin/dream-timer.d.ts +1 -0
  233. package/dist/plugin/dream-timer.d.ts.map +1 -1
  234. package/dist/plugin/embedding-bootstrap-helpers.d.ts.map +1 -1
  235. package/dist/plugin/embedding-routing.d.ts +4 -1
  236. package/dist/plugin/embedding-routing.d.ts.map +1 -1
  237. package/dist/plugin/hooks/create-session-hooks.d.ts +16 -2
  238. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  239. package/dist/plugin/rpc-handlers.d.ts +31 -1
  240. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  241. package/dist/plugin/rust-tool-backends.d.ts +1 -0
  242. package/dist/plugin/rust-tool-backends.d.ts.map +1 -1
  243. package/dist/plugin/tool-registry.d.ts.map +1 -1
  244. package/dist/{recomp-orchestrator-q98r6rga.js → recomp-orchestrator-m33b3rk9.js} +5 -5
  245. package/dist/{send-session-notification-hdh02wy9.js → send-session-notification-1qeqkswb.js} +6 -4
  246. package/dist/shared/child-session-teardown.d.ts +34 -0
  247. package/dist/shared/child-session-teardown.d.ts.map +1 -0
  248. package/dist/shared/keep-subagents.d.ts +1 -1
  249. package/dist/shared/keep-subagents.d.ts.map +1 -1
  250. package/dist/shared/model-suggestion-retry.d.ts +1 -1
  251. package/dist/shared/opencode-db-path.d.ts +24 -0
  252. package/dist/shared/opencode-db-path.d.ts.map +1 -0
  253. package/dist/shared/prompt-surface-runtime.d.ts +10 -5
  254. package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
  255. package/dist/shared/resolve-fallbacks.d.ts +1 -1
  256. package/dist/shared/rpc-types.d.ts +121 -0
  257. package/dist/shared/rpc-types.d.ts.map +1 -1
  258. package/dist/shared/sqlite.d.ts +42 -0
  259. package/dist/shared/sqlite.d.ts.map +1 -1
  260. package/dist/shared/status-detail-text.d.ts +3 -1
  261. package/dist/shared/status-detail-text.d.ts.map +1 -1
  262. package/dist/shared/status-summary.d.ts +30 -0
  263. package/dist/shared/status-summary.d.ts.map +1 -0
  264. package/dist/shared/subagent-runner.d.ts +17 -10
  265. package/dist/shared/subagent-runner.d.ts.map +1 -1
  266. package/dist/shared/tag-transcript.d.ts.map +1 -1
  267. package/dist/shared/tail-hygiene-status.d.ts +1 -0
  268. package/dist/shared/tail-hygiene-status.d.ts.map +1 -1
  269. package/dist/shared/transcript.d.ts +6 -0
  270. package/dist/shared/transcript.d.ts.map +1 -1
  271. package/dist/shared/user-facing-codes.d.ts +191 -0
  272. package/dist/shared/user-facing-codes.d.ts.map +1 -0
  273. package/dist/shared/window-geometry.d.ts +23 -0
  274. package/dist/shared/window-geometry.d.ts.map +1 -1
  275. package/dist/shared/write-transaction-timing.d.ts +1 -1
  276. package/dist/shared/write-transaction-timing.d.ts.map +1 -1
  277. package/dist/{storage-meta-session-dvwfw778.js → storage-meta-session-e6g0mmec.js} +2 -2
  278. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  279. package/dist/tools/ctx-memory/verification-recording.d.ts.map +1 -1
  280. package/dist/tools/ctx-note/constants.d.ts +1 -1
  281. package/dist/tools/ctx-note/constants.d.ts.map +1 -1
  282. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  283. package/dist/tools/ctx-note/types.d.ts +1 -0
  284. package/dist/tools/ctx-note/types.d.ts.map +1 -1
  285. package/dist/tools/ctx-reduce/tools.d.ts +10 -1
  286. package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
  287. package/dist/tools/ctx-search/constants.d.ts +1 -1
  288. package/dist/tools/ctx-search/constants.d.ts.map +1 -1
  289. package/dist/tools/light-descriptions.d.ts +2 -2
  290. package/dist/tools/light-descriptions.d.ts.map +1 -1
  291. package/package.json +2 -3
  292. package/src/agents/hidden-agent-registrations.ts +3 -15
  293. package/src/agents/magic-context-prompt.test.ts +7 -5
  294. package/src/agents/magic-context-prompt.ts +22 -30
  295. package/src/agents/permissions.test.ts +1 -42
  296. package/src/agents/permissions.ts +1 -24
  297. package/src/config/agent-disable.ts +5 -22
  298. package/src/config/index.test.ts +126 -15
  299. package/src/config/index.ts +41 -6
  300. package/src/config/latch-permanence-guard.test.ts +4 -0
  301. package/src/config/migrate-config-location.test.ts +39 -6
  302. package/src/config/migrate-config-location.ts +18 -31
  303. package/src/config/profiles.ts +1 -1
  304. package/src/config/project-security.hostile-matrix.test.ts +0 -8
  305. package/src/config/project-security.test.ts +21 -24
  306. package/src/config/project-security.ts +115 -14
  307. package/src/config/protected-tokens.test.ts +235 -0
  308. package/src/config/removed-agent-config.ts +45 -0
  309. package/src/config/removed-agent-source-fence.test.ts +56 -0
  310. package/src/config/schema/magic-context.test.ts +50 -42
  311. package/src/config/schema/magic-context.ts +70 -37
  312. package/src/shared/child-session-teardown.test.ts +218 -0
  313. package/src/shared/child-session-teardown.ts +66 -0
  314. package/src/shared/keep-subagents.ts +9 -14
  315. package/src/shared/model-suggestion-retry.ts +1 -1
  316. package/src/shared/opencode-db-path.test.ts +196 -0
  317. package/src/shared/opencode-db-path.ts +215 -0
  318. package/src/shared/prompt-surface-a1-golden.md +50 -35
  319. package/src/shared/prompt-surface-runtime.test.ts +28 -0
  320. package/src/shared/prompt-surface-runtime.ts +22 -5
  321. package/src/shared/resolve-fallbacks.ts +1 -1
  322. package/src/shared/rpc-types.ts +128 -0
  323. package/src/shared/session-messages-bounded.test.ts +1 -1
  324. package/src/shared/sqlite-import-fence.test.ts +19 -0
  325. package/src/shared/sqlite.test.ts +27 -1
  326. package/src/shared/sqlite.ts +204 -1
  327. package/src/shared/status-detail-text.test.ts +92 -20
  328. package/src/shared/status-detail-text.ts +24 -2
  329. package/src/shared/status-summary.ts +167 -0
  330. package/src/shared/subagent-runner.ts +17 -10
  331. package/src/shared/tag-transcript.ts +33 -21
  332. package/src/shared/tail-hygiene-status.ts +8 -0
  333. package/src/shared/transcript.ts +7 -0
  334. package/src/shared/user-facing-codes.test.ts +140 -0
  335. package/src/shared/user-facing-codes.ts +276 -0
  336. package/src/shared/window-geometry.test.ts +44 -0
  337. package/src/shared/window-geometry.ts +89 -11
  338. package/src/shared/write-transaction-attribution.test.ts +241 -0
  339. package/src/shared/write-transaction-timing.ts +2 -1
  340. package/src/tui/index.tsx +44 -11
  341. package/src/tui/slots/sidebar-content.tsx +12 -7
  342. package/src/tui-compiled/index.tsx +662 -649
  343. package/src/tui-compiled/slots/sidebar-content.tsx +301 -305
  344. package/dist/agents/sidekick.d.ts +0 -2
  345. package/dist/agents/sidekick.d.ts.map +0 -1
  346. package/dist/features/magic-context/defaults.d.ts +0 -2
  347. package/dist/features/magic-context/defaults.d.ts.map +0 -1
  348. package/dist/features/magic-context/sidekick/agent.d.ts +0 -14
  349. package/dist/features/magic-context/sidekick/agent.d.ts.map +0 -1
  350. package/dist/features/magic-context/sidekick/core.d.ts +0 -38
  351. package/dist/features/magic-context/sidekick/core.d.ts.map +0 -1
  352. package/dist/features/magic-context/sidekick/index.d.ts +0 -3
  353. package/dist/features/magic-context/sidekick/index.d.ts.map +0 -1
  354. package/dist/hooks/magic-context/boundary-execution.d.ts +0 -27
  355. package/dist/hooks/magic-context/boundary-execution.d.ts.map +0 -1
  356. package/dist/index-raatkvw5.js +0 -360
  357. package/src/agents/sidekick.ts +0 -1
  358. package/src/features/magic-context/defaults.ts +0 -1
@@ -0,0 +1,235 @@
1
+ /// <reference types="bun-types" />
2
+
3
+ import { describe, expect, it } from "bun:test";
4
+ import { readFileSync } from "node:fs";
5
+ import { resolve } from "node:path";
6
+ import { parsePluginConfig, resetProtectedTagsDeprecationWarningForTest } from "./index";
7
+ import { constrainProjectThresholdOverrides } from "./project-security";
8
+ import { deriveDefaultProtectedTokens, MagicContextConfigSchema } from "./schema/magic-context";
9
+
10
+ describe("protected_tokens config and derivation", () => {
11
+ describe("derived-default table asserted by value", () => {
12
+ it("asserts 100k -> 8,000", () => {
13
+ expect(deriveDefaultProtectedTokens(100_000)).toBe(8_000);
14
+ });
15
+
16
+ it("asserts 200k -> 16,000", () => {
17
+ expect(deriveDefaultProtectedTokens(200_000)).toBe(16_000);
18
+ });
19
+
20
+ it("asserts 372k -> 18,600", () => {
21
+ expect(deriveDefaultProtectedTokens(372_000)).toBe(18_600);
22
+ });
23
+
24
+ it("asserts 872k -> 43,600", () => {
25
+ expect(deriveDefaultProtectedTokens(872_000)).toBe(43_600);
26
+ });
27
+
28
+ it("asserts 1M -> 50,000", () => {
29
+ expect(deriveDefaultProtectedTokens(1_000_000)).toBe(50_000);
30
+ });
31
+ });
32
+
33
+ describe("override range enforced at both ends", () => {
34
+ it("accepts values within 4_000 .. 1_000_000", () => {
35
+ expect(
36
+ MagicContextConfigSchema.parse({ protected_tokens: 4_000 }).protected_tokens,
37
+ ).toBe(4_000);
38
+ expect(
39
+ MagicContextConfigSchema.parse({ protected_tokens: 30_000 }).protected_tokens,
40
+ ).toBe(30_000);
41
+ expect(
42
+ MagicContextConfigSchema.parse({ protected_tokens: 1_000_000 }).protected_tokens,
43
+ ).toBe(1_000_000);
44
+ });
45
+
46
+ it("rejects values below 4_000", () => {
47
+ expect(() => MagicContextConfigSchema.parse({ protected_tokens: 3_999 })).toThrow();
48
+ expect(() => MagicContextConfigSchema.parse({ protected_tokens: 0 })).toThrow();
49
+ expect(() => MagicContextConfigSchema.parse({ protected_tokens: -100 })).toThrow();
50
+ });
51
+
52
+ it("rejects values above 1_000_000", () => {
53
+ expect(() => MagicContextConfigSchema.parse({ protected_tokens: 1_000_001 })).toThrow();
54
+ });
55
+ });
56
+
57
+ describe("config-form parity tests against pinned Ruling 5 shape", () => {
58
+ // Shared expectation: any non-positive-integer shape is an invalid leaf
59
+ // (warning emitted, fall back to derived floor, plugin remains enabled).
60
+ it("(a) object form without default is an invalid leaf and falls back to derived", () => {
61
+ const raw = { protected_tokens: { "anthropic/claude-3-5-sonnet": 30_000 } };
62
+ const parsed = MagicContextConfigSchema.safeParse(raw);
63
+ expect(parsed.success).toBe(false);
64
+
65
+ const recovered = parsePluginConfig(raw);
66
+ expect(recovered.protected_tokens).toBeUndefined();
67
+ expect(
68
+ recovered.configWarnings?.some((w) =>
69
+ w.includes('"protected_tokens": invalid value'),
70
+ ),
71
+ ).toBe(true);
72
+ const resolvedFloor =
73
+ recovered.protected_tokens ?? deriveDefaultProtectedTokens(200_000);
74
+ expect(resolvedFloor).toBe(16_000);
75
+ });
76
+
77
+ it("(b) unmatched model key in object form is an invalid leaf and falls back to derived", () => {
78
+ const raw = { protected_tokens: { unmatched_model: 25_000 } };
79
+ const parsed = MagicContextConfigSchema.safeParse(raw);
80
+ expect(parsed.success).toBe(false);
81
+
82
+ const recovered = parsePluginConfig(raw);
83
+ expect(recovered.protected_tokens).toBeUndefined();
84
+ expect(
85
+ recovered.configWarnings?.some((w) =>
86
+ w.includes('"protected_tokens": invalid value'),
87
+ ),
88
+ ).toBe(true);
89
+ const resolvedFloor =
90
+ recovered.protected_tokens ?? deriveDefaultProtectedTokens(200_000);
91
+ expect(resolvedFloor).toBe(16_000);
92
+ });
93
+
94
+ it("(c) fractional override is an invalid leaf and falls back to derived", () => {
95
+ const raw = { protected_tokens: 16000.5 };
96
+ const parsed = MagicContextConfigSchema.safeParse(raw);
97
+ expect(parsed.success).toBe(false);
98
+
99
+ const recovered = parsePluginConfig(raw);
100
+ expect(recovered.protected_tokens).toBeUndefined();
101
+ expect(
102
+ recovered.configWarnings?.some((w) =>
103
+ w.includes('"protected_tokens": invalid value'),
104
+ ),
105
+ ).toBe(true);
106
+ const resolvedFloor =
107
+ recovered.protected_tokens ?? deriveDefaultProtectedTokens(200_000);
108
+ expect(resolvedFloor).toBe(16_000);
109
+ });
110
+ });
111
+
112
+ describe("precedence: project (raise-only, only if >= resolved user value) > user > derived", () => {
113
+ it("project raises user value when >= resolved user value", () => {
114
+ const mergedRaw: Record<string, unknown> = { protected_tokens: 20_000 };
115
+ const projectRaw = { protected_tokens: 30_000 };
116
+ const warnings = constrainProjectThresholdOverrides({
117
+ mergedRaw,
118
+ projectRaw,
119
+ trustedBaseConfig: { protected_tokens: 20_000 },
120
+ });
121
+ expect(mergedRaw.protected_tokens).toBe(30_000);
122
+ expect(warnings).toHaveLength(0);
123
+ });
124
+
125
+ it("project lower than user value is rejected with warning and user value stands", () => {
126
+ const mergedRaw: Record<string, unknown> = { protected_tokens: 25_000 };
127
+ const projectRaw = { protected_tokens: 10_000 };
128
+ const warnings = constrainProjectThresholdOverrides({
129
+ mergedRaw,
130
+ projectRaw,
131
+ trustedBaseConfig: { protected_tokens: 25_000 },
132
+ });
133
+ expect(mergedRaw.protected_tokens).toBe(25_000);
134
+ expect(warnings.some((w) => w.includes("protected_tokens"))).toBe(true);
135
+ });
136
+
137
+ it("rejects a project object and preserves the trusted user scalar", () => {
138
+ const mergedRaw: Record<string, unknown> = {
139
+ protected_tokens: { default: 35_000 },
140
+ };
141
+ const projectRaw = { protected_tokens: { default: 35_000 } };
142
+ const warnings = constrainProjectThresholdOverrides({
143
+ mergedRaw,
144
+ projectRaw,
145
+ trustedBaseConfig: { protected_tokens: 20_000 },
146
+ });
147
+ expect(mergedRaw.protected_tokens).toBe(20_000);
148
+ expect(warnings.some((w) => w.includes("protected_tokens"))).toBe(true);
149
+ });
150
+
151
+ it("rejects a project object and falls back to derivation when the user omitted the setting", () => {
152
+ const mergedRaw: Record<string, unknown> = {
153
+ protected_tokens: { default: 35_000 },
154
+ };
155
+ const projectRaw = { protected_tokens: { default: 35_000 } };
156
+ const warnings = constrainProjectThresholdOverrides({
157
+ mergedRaw,
158
+ projectRaw,
159
+ trustedBaseConfig: {},
160
+ });
161
+ expect(mergedRaw.protected_tokens).toBeUndefined();
162
+ expect(warnings.some((w) => w.includes("protected_tokens"))).toBe(true);
163
+ });
164
+
165
+ it("project override applies when user tier is omitted", () => {
166
+ const mergedRaw: Record<string, unknown> = {};
167
+ const projectRaw = { protected_tokens: 32_000 };
168
+ const warnings = constrainProjectThresholdOverrides({
169
+ mergedRaw,
170
+ projectRaw,
171
+ trustedBaseConfig: {},
172
+ });
173
+ expect(mergedRaw.protected_tokens).toBe(32_000);
174
+ expect(warnings).toHaveLength(0);
175
+ });
176
+ });
177
+
178
+ describe("root configuration reference", () => {
179
+ const reference = readFileSync(
180
+ resolve(import.meta.dir, "../../../../CONFIGURATION.md"),
181
+ "utf8",
182
+ );
183
+
184
+ it("documents protected_tokens as live and protected_tags only as deprecated and ignored", () => {
185
+ expect(reference).toContain("| `protected_tokens` |");
186
+ expect(reference).not.toContain("| `protected_tags` |");
187
+ expect(reference).toContain("`protected_tags` is deprecated and ignored");
188
+ });
189
+ });
190
+
191
+ describe("protected_tags deprecation", () => {
192
+ it("is parsed at any value (including 0 and 101) with parse succeeding and no numeric conversion", () => {
193
+ resetProtectedTagsDeprecationWarningForTest();
194
+ const config0 = MagicContextConfigSchema.parse({ protected_tags: 0 });
195
+ expect(config0.protected_tags).toBe(0);
196
+
197
+ const config101 = MagicContextConfigSchema.parse({ protected_tags: 101 });
198
+ expect(config101.protected_tags).toBe(101);
199
+
200
+ const configArbitrary = MagicContextConfigSchema.parse({
201
+ protected_tags: "legacy-string",
202
+ });
203
+ expect(configArbitrary.protected_tags).toBe("legacy-string");
204
+
205
+ // Verify no numeric conversion happened
206
+ expect(typeof configArbitrary.protected_tags).toBe("string");
207
+ });
208
+
209
+ it("emits a once-per-process loud deprecation warning naming the replacement", () => {
210
+ resetProtectedTagsDeprecationWarningForTest();
211
+ const warnCalls: string[] = [];
212
+ const originalWarn = console.warn;
213
+ console.warn = (...args: unknown[]) => warnCalls.push(args.map(String).join(" "));
214
+
215
+ try {
216
+ const res1 = parsePluginConfig({ protected_tags: 20 });
217
+ expect(
218
+ res1.configWarnings?.some((w) =>
219
+ w.includes(
220
+ "protected_tags is deprecated and ignored; use protected_tokens instead.",
221
+ ),
222
+ ),
223
+ ).toBe(true);
224
+ expect(warnCalls).toHaveLength(1);
225
+ expect(warnCalls[0]).toContain("protected_tokens");
226
+
227
+ // Second parse in same process must NOT log to console again
228
+ parsePluginConfig({ protected_tags: 10 });
229
+ expect(warnCalls).toHaveLength(1);
230
+ } finally {
231
+ console.warn = originalWarn;
232
+ }
233
+ });
234
+ });
235
+ });
@@ -0,0 +1,45 @@
1
+ const REMOVED_AGENT_CONFIG_KEY = "sidekick";
2
+
3
+ export const REMOVED_AGENT_CONFIG_WARNING = `The "${REMOVED_AGENT_CONFIG_KEY}" configuration was removed and is ignored.`;
4
+
5
+ function isPlainObject(value: unknown): value is Record<string, unknown> {
6
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7
+ }
8
+
9
+ /**
10
+ * Remove the retired agent block before profile resolution or schema parsing.
11
+ * The same warning array may be shared across user and project layers so one
12
+ * load reports the removal once while preserving every unrelated setting.
13
+ */
14
+ export function stripRemovedAgentConfig(
15
+ rawConfig: Record<string, unknown>,
16
+ warnings: string[],
17
+ ): Record<string, unknown> {
18
+ let removed = false;
19
+ const patched = { ...rawConfig };
20
+
21
+ if (Object.hasOwn(patched, REMOVED_AGENT_CONFIG_KEY)) {
22
+ delete patched[REMOVED_AGENT_CONFIG_KEY];
23
+ removed = true;
24
+ }
25
+
26
+ if (isPlainObject(patched.profiles)) {
27
+ const profiles = { ...patched.profiles };
28
+ let profilesChanged = false;
29
+ for (const [name, value] of Object.entries(profiles)) {
30
+ if (!isPlainObject(value) || !Object.hasOwn(value, REMOVED_AGENT_CONFIG_KEY)) continue;
31
+ const profile = { ...value };
32
+ delete profile[REMOVED_AGENT_CONFIG_KEY];
33
+ profiles[name] = profile;
34
+ profilesChanged = true;
35
+ removed = true;
36
+ }
37
+ if (profilesChanged) patched.profiles = profiles;
38
+ }
39
+
40
+ if (removed && !warnings.includes(REMOVED_AGENT_CONFIG_WARNING)) {
41
+ warnings.push(REMOVED_AGENT_CONFIG_WARNING);
42
+ }
43
+
44
+ return removed ? patched : rawConfig;
45
+ }
@@ -0,0 +1,56 @@
1
+ /// <reference types="bun-types" />
2
+
3
+ import { describe, expect, it } from "bun:test";
4
+ import { readdirSync, readFileSync, statSync } from "node:fs";
5
+ import { join, relative } from "node:path";
6
+
7
+ const RETIRED_AGENT_NAME = ["side", "kick"].join("");
8
+ const RETIRED_AGENT_PATTERN = new RegExp(RETIRED_AGENT_NAME, "gi");
9
+ const REPO_ROOT = join(__dirname, "..", "..", "..", "..");
10
+ const WARNING_SOURCE = join(
11
+ REPO_ROOT,
12
+ "packages",
13
+ "plugin",
14
+ "src",
15
+ "config",
16
+ "removed-agent-config.ts",
17
+ );
18
+ const SOURCE_ROOTS = [
19
+ join(REPO_ROOT, "packages", "plugin", "src"),
20
+ join(REPO_ROOT, "packages", "pi-plugin", "src"),
21
+ join(REPO_ROOT, "packages", "cli", "src"),
22
+ join(REPO_ROOT, "packages", "dashboard", "src"),
23
+ join(REPO_ROOT, "packages", "dashboard", "src-tauri", "src"),
24
+ ];
25
+ const SOURCE_EXTENSIONS = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".rs", ".json"]);
26
+
27
+ function sourceFiles(directory: string, files: string[] = []): string[] {
28
+ for (const entry of readdirSync(directory)) {
29
+ if (entry === "node_modules" || entry === "dist") continue;
30
+ const path = join(directory, entry);
31
+ const stat = statSync(path);
32
+ if (stat.isDirectory()) {
33
+ sourceFiles(path, files);
34
+ continue;
35
+ }
36
+ const extension = entry.slice(entry.lastIndexOf("."));
37
+ if (stat.isFile() && SOURCE_EXTENSIONS.has(extension)) files.push(path);
38
+ }
39
+ return files;
40
+ }
41
+
42
+ describe("retired agent source fence", () => {
43
+ it("keeps only the removed-config warning key literal", () => {
44
+ const offenses: string[] = [];
45
+ for (const file of SOURCE_ROOTS.flatMap((root) => sourceFiles(root))) {
46
+ const matches = readFileSync(file, "utf8").match(RETIRED_AGENT_PATTERN) ?? [];
47
+ const allowed = file === WARNING_SOURCE && matches.length === 1;
48
+ if (!allowed && matches.length > 0) {
49
+ offenses.push(`${relative(REPO_ROOT, file)} (${matches.length})`);
50
+ }
51
+ }
52
+
53
+ expect(offenses).toEqual([]);
54
+ expect(readFileSync(WARNING_SOURCE, "utf8").match(RETIRED_AGENT_PATTERN)).toHaveLength(1);
55
+ });
56
+ });
@@ -23,7 +23,6 @@ describe("MagicContextConfigSchema", () => {
23
23
  cache_ttl: "5m",
24
24
  prompt_surface: { default: "full" },
25
25
  execute_threshold_percentage: 65,
26
- protected_tags: 20,
27
26
  clear_reasoning_age: 50,
28
27
  history_budget_percentage: DEFAULT_HISTORY_BUDGET_PERCENTAGE,
29
28
  historian_timeout_ms: DEFAULT_HISTORIAN_TIMEOUT_MS,
@@ -46,7 +45,6 @@ describe("MagicContextConfigSchema", () => {
46
45
  expect(result.historian_timeout_ms).toBeGreaterThanOrEqual(10 * 60_000);
47
46
  expect(result.historian).toBeUndefined();
48
47
  expect(result.dreamer).toBeUndefined();
49
- expect(result.sidekick).toBeUndefined();
50
48
  expect(result.pi).toBeUndefined();
51
49
  expect(result.mural).toEqual({ enabled: false });
52
50
  });
@@ -107,6 +105,7 @@ describe("MagicContextConfigSchema", () => {
107
105
  },
108
106
  temporal_awareness: false,
109
107
  keep_subagents: false,
108
+ debug_rpc: false,
110
109
  todowrite: {
111
110
  enabled: false,
112
111
  overlay: false,
@@ -145,15 +144,6 @@ describe("MagicContextConfigSchema", () => {
145
144
  pi: {
146
145
  subagent_extensions: ["@example/provider", "./extensions/local.ts"],
147
146
  },
148
- sidekick: {
149
- disable: false,
150
- model: "qwen-test",
151
- fallback_models: ["qwen-fallback"],
152
- temperature: 0.1,
153
- variant: "fast",
154
- timeout_ms: 12_000,
155
- system_prompt: "Custom prompt",
156
- },
157
147
  compaction: {
158
148
  enabled: true,
159
149
  },
@@ -177,19 +167,6 @@ describe("MagicContextConfigSchema", () => {
177
167
  ).toBe(false);
178
168
  });
179
169
 
180
- it("applies sidekick defaults when the object is present", () => {
181
- const result = MagicContextConfigSchema.parse({
182
- sidekick: {
183
- model: "github-copilot/gpt-5.4",
184
- },
185
- });
186
-
187
- expect(result.sidekick).toEqual({
188
- model: "github-copilot/gpt-5.4",
189
- timeout_ms: 30000,
190
- });
191
- });
192
-
193
170
  it("accepts disable on hidden agents and strips deprecated top-level enabled", () => {
194
171
  const result = MagicContextConfigSchema.parse({
195
172
  historian: { disable: true },
@@ -203,14 +180,11 @@ describe("MagicContextConfigSchema", () => {
203
180
  "maintain-docs": { schedule: "0 * * * *" },
204
181
  },
205
182
  },
206
- sidekick: { disable: true, enabled: true },
207
183
  });
208
184
 
209
185
  expect(result.historian?.disable).toBe(true);
210
186
  expect(result.dreamer?.disable).toBe(true);
211
- expect(result.sidekick?.disable).toBe(true);
212
187
  expect("enabled" in (result.dreamer as Record<string, unknown>)).toBe(false);
213
- expect("enabled" in (result.sidekick as Record<string, unknown>)).toBe(false);
214
188
  expect(result.dreamer?.tasks["review-user-memories"].schedule).toBe("");
215
189
  expect(result.dreamer?.tasks["maintain-docs"].schedule).toBe("0 * * * *");
216
190
  expect(result.dreamer?.tasks["classify-memories"].schedule).toBe("0 6 * * *");
@@ -353,10 +327,6 @@ describe("MagicContextConfigSchema", () => {
353
327
  thinking_level: "inherit",
354
328
  },
355
329
  },
356
- sidekick: {
357
- model: "anthropic/work-sidekick",
358
- fallback_models: ["openai/work-sidekick-fallback"],
359
- },
360
330
  },
361
331
  },
362
332
  });
@@ -376,7 +346,6 @@ describe("MagicContextConfigSchema", () => {
376
346
  { model: "opencode/work-historian-fallback", thinking_level: "inherit" },
377
347
  ]);
378
348
  expect(result.profiles?.work?.dreamer?.omp?.thinking_level).toBe("inherit");
379
- expect(result.profiles?.work?.sidekick?.model).toBe("anthropic/work-sidekick");
380
349
  });
381
350
 
382
351
  it("rejects timeout_minutes in a dreamer profile", () => {
@@ -432,7 +401,7 @@ describe("MagicContextConfigSchema", () => {
432
401
  },
433
402
  },
434
403
  { work: { dreamer: { tasks: { verify: { schedule: "0 3 * * *" } } } } },
435
- { work: { sidekick: { timeout_ms: 60_000 } } },
404
+ { work: { dreamer: { timeout_ms: 60_000 } } },
436
405
  ];
437
406
 
438
407
  for (const profiles of profilesWithExcludedFields) {
@@ -667,17 +636,27 @@ describe("MagicContextConfigSchema", () => {
667
636
  ).toThrow();
668
637
  });
669
638
 
670
- it("rejects protected_tags greater than 100", () => {
671
- expect(() => MagicContextConfigSchema.parse({ protected_tags: 101 })).toThrow();
672
- });
673
-
674
- it("rejects protected_tags less than 1", () => {
675
- expect(() => MagicContextConfigSchema.parse({ protected_tags: 0 })).toThrow();
639
+ it("accepts protected_tags at any value including 0 and 101 as deprecated inert key", () => {
640
+ expect(MagicContextConfigSchema.parse({ protected_tags: 101 }).protected_tags).toBe(
641
+ 101,
642
+ );
643
+ expect(MagicContextConfigSchema.parse({ protected_tags: 0 }).protected_tags).toBe(0);
644
+ expect(MagicContextConfigSchema.parse({ protected_tags: 20 }).protected_tags).toBe(20);
676
645
  });
677
646
 
678
- it("accepts protected_tags boundary values", () => {
679
- expect(MagicContextConfigSchema.parse({ protected_tags: 1 }).protected_tags).toBe(1);
680
- expect(MagicContextConfigSchema.parse({ protected_tags: 20 }).protected_tags).toBe(20);
647
+ it("enforces protected_tokens override range at both ends", () => {
648
+ expect(() => MagicContextConfigSchema.parse({ protected_tokens: 3999 })).toThrow();
649
+ expect(() => MagicContextConfigSchema.parse({ protected_tokens: 1_000_001 })).toThrow();
650
+ expect(() => MagicContextConfigSchema.parse({ protected_tokens: 30000.5 })).toThrow();
651
+ expect(
652
+ MagicContextConfigSchema.parse({ protected_tokens: 4000 }).protected_tokens,
653
+ ).toBe(4000);
654
+ expect(
655
+ MagicContextConfigSchema.parse({ protected_tokens: 1_000_000 }).protected_tokens,
656
+ ).toBe(1_000_000);
657
+ expect(
658
+ MagicContextConfigSchema.parse({ protected_tokens: 30000 }).protected_tokens,
659
+ ).toBe(30000);
681
660
  });
682
661
 
683
662
  it("rejects clear_reasoning_age below minimum", () => {
@@ -719,6 +698,35 @@ describe("MagicContextConfigSchema", () => {
719
698
  ).toThrow();
720
699
  });
721
700
 
701
+ it("preserves embedding instruction prefixes byte-for-byte and accepts false", () => {
702
+ const queryInstruction = "Instruct: custom task\nQuery: ";
703
+ const documentPrefix = "search_document: ";
704
+ const parsed = MagicContextConfigSchema.parse({
705
+ embedding: {
706
+ provider: "openai-compatible",
707
+ endpoint: "http://localhost:1234/v1",
708
+ model: "custom/model",
709
+ query_instruction: queryInstruction,
710
+ document_prefix: documentPrefix,
711
+ },
712
+ }).embedding;
713
+
714
+ expect(parsed).toMatchObject({
715
+ query_instruction: queryInstruction,
716
+ document_prefix: documentPrefix,
717
+ });
718
+ expect(
719
+ MagicContextConfigSchema.parse({
720
+ embedding: {
721
+ provider: "openai-compatible",
722
+ endpoint: "http://localhost:1234/v1",
723
+ model: "custom/model",
724
+ query_instruction: false,
725
+ },
726
+ }).embedding,
727
+ ).toMatchObject({ query_instruction: false });
728
+ });
729
+
722
730
  it("defaults local embedding runtime to auto and accepts explicit overrides", () => {
723
731
  expect(
724
732
  MagicContextConfigSchema.parse({ embedding: { provider: "local" } }).embedding,