@cortexkit/opencode-magic-context 0.33.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/dist/config/agent-disable.d.ts +22 -0
  2. package/dist/config/agent-disable.d.ts.map +1 -1
  3. package/dist/config/index.d.ts.map +1 -1
  4. package/dist/config/project-security.d.ts +7 -0
  5. package/dist/config/project-security.d.ts.map +1 -1
  6. package/dist/config/schema/magic-context.d.ts +144 -24
  7. package/dist/config/schema/magic-context.d.ts.map +1 -1
  8. package/dist/config/transform-mode.d.ts +2 -0
  9. package/dist/config/transform-mode.d.ts.map +1 -1
  10. package/dist/{conflict-warning-hook-bwa99a04.js → conflict-warning-hook-fvpfvt0w.js} +1 -1
  11. package/dist/{derive-budgets-e9j09sjr.js → derive-budgets-9crp0cvd.js} +1 -1
  12. package/dist/features/builtin-commands/commands.d.ts +1 -1
  13. package/dist/features/builtin-commands/commands.d.ts.map +1 -1
  14. package/dist/features/magic-context/compaction-marker.d.ts +106 -0
  15. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  16. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +0 -2
  17. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  18. package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
  19. package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  21. package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
  22. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  23. package/dist/features/magic-context/dreamer/task-registry.d.ts +0 -1
  24. package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
  25. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  26. package/dist/features/magic-context/fail-closed-block.d.ts +10 -0
  27. package/dist/features/magic-context/fail-closed-block.d.ts.map +1 -1
  28. package/dist/features/magic-context/git-commits/index.d.ts +2 -2
  29. package/dist/features/magic-context/git-commits/index.d.ts.map +1 -1
  30. package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts +0 -2
  31. package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts.map +1 -1
  32. package/dist/features/magic-context/git-commits/storage-git-commits.d.ts +0 -13
  33. package/dist/features/magic-context/git-commits/storage-git-commits.d.ts.map +1 -1
  34. package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
  35. package/dist/features/magic-context/memory/embedding-local.d.ts +7 -1
  36. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  37. package/dist/features/magic-context/memory/embedding.d.ts +1 -2
  38. package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
  39. package/dist/features/magic-context/memory/memory-migration.d.ts +0 -6
  40. package/dist/features/magic-context/memory/memory-migration.d.ts.map +1 -1
  41. package/dist/features/magic-context/memory/project-identity.d.ts +2 -6
  42. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  43. package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts +0 -1
  44. package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts.map +1 -1
  45. package/dist/features/magic-context/memory/storage-memory.d.ts +1 -6
  46. package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -1
  47. package/dist/features/magic-context/memory/verification-paths.d.ts +0 -1
  48. package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
  49. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  50. package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
  51. package/dist/features/magic-context/mural/render-mural.d.ts.map +1 -1
  52. package/dist/features/magic-context/mural/storage-mural.d.ts +0 -1
  53. package/dist/features/magic-context/mural/storage-mural.d.ts.map +1 -1
  54. package/dist/features/magic-context/overflow-detection.d.ts +8 -1
  55. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  56. package/dist/features/magic-context/project-embedding-registry.d.ts +16 -2
  57. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  58. package/dist/features/magic-context/scheduler.d.ts.map +1 -1
  59. package/dist/features/magic-context/schema-fence-probe.d.ts +28 -0
  60. package/dist/features/magic-context/schema-fence-probe.d.ts.map +1 -0
  61. package/dist/features/magic-context/sidekick/agent.d.ts.map +1 -1
  62. package/dist/features/magic-context/smart-notes/capabilities.d.ts +0 -2
  63. package/dist/features/magic-context/smart-notes/capabilities.d.ts.map +1 -1
  64. package/dist/features/magic-context/smart-notes/compiler.d.ts +0 -1
  65. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  66. package/dist/features/magic-context/smart-notes/types.d.ts +0 -16
  67. package/dist/features/magic-context/smart-notes/types.d.ts.map +1 -1
  68. package/dist/features/magic-context/storage-db.d.ts +35 -1
  69. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  70. package/dist/features/magic-context/storage-meta-persisted.d.ts +38 -5
  71. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  72. package/dist/features/magic-context/storage-meta.d.ts +1 -1
  73. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  74. package/dist/features/magic-context/storage.d.ts +1 -1
  75. package/dist/features/magic-context/storage.d.ts.map +1 -1
  76. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
  77. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts +0 -2
  78. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
  79. package/dist/hooks/auto-update-checker/types.d.ts +0 -3
  80. package/dist/hooks/auto-update-checker/types.d.ts.map +1 -1
  81. package/dist/hooks/magic-context/boundary-execution.d.ts +1 -1
  82. package/dist/hooks/magic-context/boundary-execution.d.ts.map +1 -1
  83. package/dist/hooks/magic-context/cache-busting-signals.d.ts +1 -1
  84. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
  85. package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
  86. package/dist/hooks/magic-context/child-session-spawn.d.ts +26 -0
  87. package/dist/hooks/magic-context/child-session-spawn.d.ts.map +1 -0
  88. package/dist/hooks/magic-context/command-handler.d.ts +2 -0
  89. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  90. package/dist/hooks/magic-context/compaction-marker-manager.d.ts +49 -0
  91. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
  92. package/dist/hooks/magic-context/compaction-off-transition.d.ts +96 -0
  93. package/dist/hooks/magic-context/compaction-off-transition.d.ts.map +1 -0
  94. package/dist/hooks/magic-context/compartment-parser.d.ts +12 -0
  95. package/dist/hooks/magic-context/compartment-parser.d.ts.map +1 -1
  96. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -0
  97. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  98. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  99. package/dist/hooks/magic-context/compartment-runner-mapping.d.ts +0 -12
  100. package/dist/hooks/magic-context/compartment-runner-mapping.d.ts.map +1 -1
  101. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
  102. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  103. package/dist/hooks/magic-context/compartment-trigger.d.ts +12 -5
  104. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  105. package/dist/hooks/magic-context/ctx-reduce-availability.d.ts +47 -1
  106. package/dist/hooks/magic-context/ctx-reduce-availability.d.ts.map +1 -1
  107. package/dist/hooks/magic-context/emergency-drop.d.ts +2 -2
  108. package/dist/hooks/magic-context/event-handler.d.ts +7 -0
  109. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  110. package/dist/hooks/magic-context/event-resolvers.d.ts +13 -21
  111. package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
  112. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +2 -0
  113. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  114. package/dist/hooks/magic-context/heuristic-cleanup.d.ts +1 -1
  115. package/dist/hooks/magic-context/historian-prompt.generated.d.ts +1 -1
  116. package/dist/hooks/magic-context/historian-prompt.generated.d.ts.map +1 -1
  117. package/dist/hooks/magic-context/hook-handlers.d.ts +1 -0
  118. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  119. package/dist/hooks/magic-context/hook.d.ts +11 -1
  120. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  121. package/dist/hooks/magic-context/inject-compartments.d.ts +18 -0
  122. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  123. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  124. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  125. package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
  126. package/dist/hooks/magic-context/rust-mode-transform.d.ts +3 -0
  127. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  128. package/dist/hooks/magic-context/send-session-notification.d.ts +20 -1
  129. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  130. package/dist/hooks/magic-context/sentinel.d.ts +39 -0
  131. package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
  132. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  133. package/dist/hooks/magic-context/tool-drop-target.d.ts +19 -0
  134. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  135. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +3 -0
  136. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  137. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +30 -0
  138. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  139. package/dist/hooks/magic-context/transform.d.ts +27 -0
  140. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  141. package/dist/{index-kxz4tn6m.js → index-56yjaeb2.js} +56 -4
  142. package/dist/{index-bmkea2dq.js → index-b563sga5.js} +40 -287
  143. package/dist/{index-y1c9tcm3.js → index-cn960ffd.js} +101 -20
  144. package/dist/{index-k5y60ymm.js → index-dtas91s5.js} +27 -6
  145. package/dist/index-fcyvznch.js +279 -0
  146. package/dist/{index-63dq2g4d.js → index-ry8rh8cv.js} +138 -24
  147. package/dist/{index-h86twgsp.js → index-s0mdn690.js} +2113 -1067
  148. package/dist/index.d.ts.map +1 -1
  149. package/dist/index.js +1356 -627
  150. package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
  151. package/dist/plugin/hooks/create-session-hooks.d.ts +19 -8
  152. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  153. package/dist/plugin/messages-transform.d.ts +10 -0
  154. package/dist/plugin/messages-transform.d.ts.map +1 -1
  155. package/dist/plugin/rpc-handlers.d.ts +3 -7
  156. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  157. package/dist/plugin/tool-registry.d.ts +8 -0
  158. package/dist/plugin/tool-registry.d.ts.map +1 -1
  159. package/dist/{recomp-orchestrator-yh7pepvx.js → recomp-orchestrator-8e82vmvb.js} +6 -5
  160. package/dist/send-session-notification-6njqewzk.js +20 -0
  161. package/dist/shared/conflict-detector.d.ts +38 -1
  162. package/dist/shared/conflict-detector.d.ts.map +1 -1
  163. package/dist/shared/conflict-fixer.d.ts +18 -1
  164. package/dist/shared/conflict-fixer.d.ts.map +1 -1
  165. package/dist/shared/context-limit-provenance.d.ts +3 -0
  166. package/dist/shared/context-limit-provenance.d.ts.map +1 -0
  167. package/dist/shared/escalation-bands.d.ts +9 -0
  168. package/dist/shared/escalation-bands.d.ts.map +1 -0
  169. package/dist/shared/format-threshold.d.ts +1 -1
  170. package/dist/shared/models-dev-cache.d.ts +29 -3
  171. package/dist/shared/models-dev-cache.d.ts.map +1 -1
  172. package/dist/shared/rpc-server.d.ts.map +1 -1
  173. package/dist/shared/rpc-types.d.ts +46 -1
  174. package/dist/shared/rpc-types.d.ts.map +1 -1
  175. package/dist/shared/sqlite.d.ts +9 -4
  176. package/dist/shared/sqlite.d.ts.map +1 -1
  177. package/dist/shared/storage-permissions.d.ts +5 -0
  178. package/dist/shared/storage-permissions.d.ts.map +1 -0
  179. package/dist/{storage-meta-session-1phy0b1z.js → storage-meta-session-xt41zbw4.js} +2 -1
  180. package/dist/{task-config-dn9k9szr.js → task-config-5nx3qfz8.js} +1 -2
  181. package/dist/tui/compaction-off.d.ts +13 -0
  182. package/dist/tui/compaction-off.d.ts.map +1 -0
  183. package/dist/tui/data/context-db.d.ts.map +1 -1
  184. package/dist/tui-compiled/compaction-off.d.ts +13 -0
  185. package/dist/tui-compiled/compaction-off.d.ts.map +1 -0
  186. package/dist/tui-compiled/data/context-db.d.ts.map +1 -1
  187. package/package.json +8 -3
  188. package/src/agents/dreamer.ts +68 -0
  189. package/src/agents/hidden-agent-registrations.ts +331 -0
  190. package/src/agents/historian.ts +3 -0
  191. package/src/agents/language-directive.test.ts +138 -0
  192. package/src/agents/language-directive.ts +121 -0
  193. package/src/agents/magic-context-prompt.language.test.ts +35 -0
  194. package/src/agents/magic-context-prompt.test.ts +292 -0
  195. package/src/agents/magic-context-prompt.ts +182 -0
  196. package/src/agents/permissions.test.ts +252 -0
  197. package/src/agents/permissions.ts +186 -0
  198. package/src/agents/sidekick.ts +1 -0
  199. package/src/agents/smart-note-compiler.ts +1 -0
  200. package/src/config/agent-disable.ts +106 -0
  201. package/src/config/compaction-accessor-guard.test.ts +82 -0
  202. package/src/config/compaction-backcompat.test.ts +52 -0
  203. package/src/config/index.test.ts +904 -0
  204. package/src/config/index.ts +601 -0
  205. package/src/config/migrate-config-location.test.ts +332 -0
  206. package/src/config/migrate-config-location.ts +635 -0
  207. package/src/config/migrate-dreamer-v2.test.ts +287 -0
  208. package/src/config/migrate-dreamer-v2.ts +336 -0
  209. package/src/config/migrate-experimental.ts +159 -0
  210. package/src/config/project-security.test.ts +366 -0
  211. package/src/config/project-security.ts +588 -0
  212. package/src/config/prune-config-leaf.test.ts +78 -0
  213. package/src/config/prune-config-leaf.ts +68 -0
  214. package/src/config/removed-config-keys.test.ts +116 -0
  215. package/src/config/schema/agent-overrides.ts +45 -0
  216. package/src/config/schema/magic-context.test.ts +358 -0
  217. package/src/config/schema/magic-context.ts +1002 -0
  218. package/src/config/transform-mode.test.ts +62 -0
  219. package/src/config/transform-mode.ts +34 -0
  220. package/src/config/variable.test.ts +323 -0
  221. package/src/config/variable.ts +192 -0
  222. package/src/features/magic-context/defaults.ts +1 -0
  223. package/src/features/magic-context/dreamer/cron.ts +243 -0
  224. package/src/features/magic-context/dreamer/task-registry.ts +104 -0
  225. package/src/shared/conflict-detector.test.ts +251 -1
  226. package/src/shared/conflict-detector.ts +84 -5
  227. package/src/shared/conflict-fixer.test.ts +309 -0
  228. package/src/shared/conflict-fixer.ts +82 -5
  229. package/src/shared/context-limit-provenance.ts +6 -0
  230. package/src/shared/escalation-bands.test.ts +23 -0
  231. package/src/shared/escalation-bands.ts +18 -0
  232. package/src/shared/format-threshold.ts +1 -1
  233. package/src/shared/models-dev-cache.test.ts +171 -0
  234. package/src/shared/models-dev-cache.ts +195 -38
  235. package/src/shared/rpc-server.ts +27 -18
  236. package/src/shared/rpc-types.ts +46 -1
  237. package/src/shared/sqlite.ts +13 -33
  238. package/src/shared/storage-permissions.ts +20 -0
  239. package/src/tui/compaction-off.test.ts +56 -0
  240. package/src/tui/compaction-off.ts +29 -0
  241. package/src/tui/data/context-db.ts +6 -0
  242. package/src/tui/index.tsx +113 -65
  243. package/src/tui/slots/sidebar-content.tsx +139 -83
  244. package/src/tui-compiled/compaction-off.ts +29 -0
  245. package/src/tui-compiled/data/context-db.ts +6 -0
  246. package/src/tui-compiled/index.tsx +558 -455
  247. package/src/tui-compiled/slots/sidebar-content.tsx +237 -161
  248. package/dist/config/schema.d.ts +0 -3
  249. package/dist/config/schema.d.ts.map +0 -1
  250. package/dist/features/magic-context/plugin-messages.d.ts +0 -75
  251. package/dist/features/magic-context/plugin-messages.d.ts.map +0 -1
  252. package/dist/hooks/magic-context/compartment-runner-state-xml.d.ts +0 -21
  253. package/dist/hooks/magic-context/compartment-runner-state-xml.d.ts.map +0 -1
  254. package/dist/index-anhrfygk.js +0 -57
  255. package/dist/send-session-notification-tghq9gnh.js +0 -11
  256. package/dist/shared/opencode-compaction-detector.d.ts +0 -2
  257. package/dist/shared/opencode-compaction-detector.d.ts.map +0 -1
  258. package/dist/shared/transcript-opencode.d.ts +0 -71
  259. package/dist/shared/transcript-opencode.d.ts.map +0 -1
  260. package/dist/tools/index.d.ts +0 -6
  261. package/dist/tools/index.d.ts.map +0 -1
  262. package/src/shared/opencode-compaction-detector.test.ts +0 -239
  263. package/src/shared/opencode-compaction-detector.ts +0 -81
  264. package/src/shared/transcript-opencode.ts +0 -302
  265. /package/dist/{index-v7fmc1s2.js → index-ygcng9t8.js} +0 -0
@@ -1,8 +1,13 @@
1
+ import {
2
+ closeQuietly,
3
+ getRawSessionMessageCountFromDb,
4
+ openCodeDbExists,
5
+ withReadOnlySessionDb
6
+ } from "./index-fcyvznch.js";
1
7
  import {
2
8
  log
3
9
  } from "./index-k1esqfwk.js";
4
10
  import {
5
- getDataDir,
6
11
  getHarness
7
12
  } from "./index-kvrcg31b.js";
8
13
  import {
@@ -50,289 +55,6 @@ function removeSystemReminders(text) {
50
55
  return text.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/gi, "").trim();
51
56
  }
52
57
 
53
- // src/hooks/magic-context/read-session-db.ts
54
- import { existsSync } from "node:fs";
55
- import { join } from "node:path";
56
-
57
- // src/shared/sqlite.ts
58
- var isBun = typeof process !== "undefined" && typeof process.versions?.bun === "string";
59
- var bunSpec = "bun:" + "sqlite";
60
- var nodeSpec = "node:" + "sqlite";
61
- var sqliteModule = isBun ? await import(bunSpec) : await import(nodeSpec);
62
- var DatabaseImpl = isBun ? sqliteModule.Database : buildNodeSqliteDatabaseClass(sqliteModule.DatabaseSync);
63
- function buildNodeSqliteDatabaseClass(DatabaseSync) {
64
- const SAVEPOINT = "mc_tx_sp";
65
-
66
- class NodeSqliteDatabase extends DatabaseSync {
67
- constructor(filename, options) {
68
- const translated = { ...options };
69
- if (options && "readonly" in options) {
70
- translated.readOnly = options.readonly;
71
- delete translated.readonly;
72
- }
73
- super(typeof filename === "string" ? filename : ":memory:", translated);
74
- }
75
- prepare(sql) {
76
- const stmt = super.prepare(sql);
77
- for (const method of ["run", "get", "all"]) {
78
- const original = stmt[method].bind(stmt);
79
- stmt[method] = (...args) => args.length === 1 && Array.isArray(args[0]) ? original(...args[0]) : original(...args);
80
- }
81
- return stmt;
82
- }
83
- transaction(fn) {
84
- const self = this;
85
- const execute = (mode, receiver, args) => {
86
- const nested = self.isTransaction === true;
87
- self.exec(nested ? `SAVEPOINT ${SAVEPOINT}` : `BEGIN${mode ? ` ${mode}` : ""}`);
88
- try {
89
- const result = fn.apply(receiver, args);
90
- self.exec(nested ? `RELEASE ${SAVEPOINT}` : "COMMIT");
91
- return result;
92
- } catch (error) {
93
- if (nested) {
94
- self.exec(`ROLLBACK TO ${SAVEPOINT}`);
95
- self.exec(`RELEASE ${SAVEPOINT}`);
96
- } else {
97
- self.exec("ROLLBACK");
98
- }
99
- throw error;
100
- }
101
- };
102
- const wrapped = function(...args) {
103
- return execute("", this, args);
104
- };
105
- wrapped.default = function(...args) {
106
- return execute("", this, args);
107
- };
108
- wrapped.deferred = function(...args) {
109
- return execute("DEFERRED", this, args);
110
- };
111
- wrapped.immediate = function(...args) {
112
- return execute("IMMEDIATE", this, args);
113
- };
114
- wrapped.exclusive = function(...args) {
115
- return execute("EXCLUSIVE", this, args);
116
- };
117
- return wrapped;
118
- }
119
- }
120
- return NodeSqliteDatabase;
121
- }
122
- var Database = DatabaseImpl;
123
- var privilegeDepth = new WeakMap;
124
- var registeredPrivilegeFunctions = new WeakSet;
125
- var privilegeUdfAvailable = new WeakSet;
126
- function registerPrivilegedWriter(db) {
127
- if (registeredPrivilegeFunctions.has(db))
128
- return;
129
- const native = db;
130
- const implementation = () => (privilegeDepth.get(db) ?? 0) > 0 ? 1 : 0;
131
- if (typeof native.function === "function") {
132
- native.function("mc_privileged_writer", implementation);
133
- } else if (typeof native.createFunction === "function") {
134
- native.createFunction("mc_privileged_writer", implementation);
135
- } else {
136
- registeredPrivilegeFunctions.add(db);
137
- return;
138
- }
139
- privilegeUdfAvailable.add(db);
140
- registeredPrivilegeFunctions.add(db);
141
- }
142
- function isInTransaction(db) {
143
- const candidate = db;
144
- return candidate.inTransaction === true || candidate.isTransaction === true;
145
- }
146
- function withPrivilegedWriter(db, operation) {
147
- registerPrivilegedWriter(db);
148
- const previousDepth = privilegeDepth.get(db) ?? 0;
149
- const nested = isInTransaction(db);
150
- const savepoint = "mc_privilege_scope";
151
- if (nested) {
152
- db.exec(`SAVEPOINT ${savepoint}`);
153
- } else {
154
- db.exec("BEGIN IMMEDIATE");
155
- }
156
- privilegeDepth.set(db, previousDepth + 1);
157
- try {
158
- if (!privilegeUdfAvailable.has(db)) {
159
- db.prepare("INSERT INTO context_privilege_state(id, enabled) VALUES (1, 1) ON CONFLICT(id) DO UPDATE SET enabled = 1").run();
160
- }
161
- const result = operation();
162
- if (!privilegeUdfAvailable.has(db) && previousDepth === 0) {
163
- db.prepare("UPDATE context_privilege_state SET enabled = 0 WHERE id = 1").run();
164
- }
165
- if (nested) {
166
- db.exec(`RELEASE ${savepoint}`);
167
- } else {
168
- db.exec("COMMIT");
169
- }
170
- if (previousDepth > 0)
171
- privilegeDepth.set(db, previousDepth);
172
- else
173
- privilegeDepth.delete(db);
174
- return result;
175
- } catch (error) {
176
- try {
177
- if (nested) {
178
- db.exec(`ROLLBACK TO ${savepoint}`);
179
- db.exec(`RELEASE ${savepoint}`);
180
- } else {
181
- db.exec("ROLLBACK");
182
- }
183
- } finally {
184
- if (previousDepth > 0)
185
- privilegeDepth.set(db, previousDepth);
186
- else
187
- privilegeDepth.delete(db);
188
- }
189
- throw error;
190
- }
191
- }
192
-
193
- // src/shared/sqlite-helpers.ts
194
- function closeQuietly(db) {
195
- if (!db)
196
- return;
197
- try {
198
- db.close();
199
- } catch {}
200
- }
201
-
202
- // src/hooks/magic-context/read-session-db.ts
203
- function getOpenCodeDbPath() {
204
- return join(getDataDir(), "opencode", "opencode.db");
205
- }
206
- function openCodeDbExists() {
207
- return existsSync(getOpenCodeDbPath());
208
- }
209
- var cachedReadOnlyDb = null;
210
- function closeCachedReadOnlyDb() {
211
- if (!cachedReadOnlyDb) {
212
- return;
213
- }
214
- try {
215
- closeQuietly(cachedReadOnlyDb.db);
216
- } catch (error) {
217
- log("[magic-context] failed to close cached OpenCode read-only DB:", error);
218
- } finally {
219
- cachedReadOnlyDb = null;
220
- }
221
- }
222
- function getReadOnlySessionDb() {
223
- const dbPath = getOpenCodeDbPath();
224
- if (cachedReadOnlyDb?.path === dbPath) {
225
- return cachedReadOnlyDb.db;
226
- }
227
- closeCachedReadOnlyDb();
228
- const db = new Database(dbPath, { readonly: true });
229
- cachedReadOnlyDb = { path: dbPath, db };
230
- return db;
231
- }
232
- function withReadOnlySessionDb(fn) {
233
- return fn(getReadOnlySessionDb());
234
- }
235
- function getRawSessionMessageCountFromDb(db, sessionId) {
236
- const row = db.prepare(`SELECT COUNT(*) as count FROM message WHERE session_id = ?
237
- AND NOT (COALESCE(json_extract(data, '$.summary'), 0) = 1
238
- AND COALESCE(json_extract(data, '$.finish'), '') = 'stop')`).get(sessionId);
239
- return typeof row?.count === "number" ? row.count : 0;
240
- }
241
- function isMidTurn(_deps, sessionId) {
242
- try {
243
- return withReadOnlySessionDb((db) => isMidTurnFromOpenCodeDb(db, sessionId));
244
- } catch (error) {
245
- log("[magic-context] failed to inspect OpenCode mid-turn state:", error);
246
- return false;
247
- }
248
- }
249
- function isMidTurnFromOpenCodeDb(db, sessionId) {
250
- const latestAssistant = db.prepare(`SELECT id,
251
- json_extract(data, '$.finish') as finish,
252
- time_created as timeCreated
253
- FROM message
254
- WHERE session_id = ?
255
- AND json_extract(data, '$.role') = 'assistant'
256
- ORDER BY time_created DESC
257
- LIMIT 1`).get(sessionId);
258
- if (typeof latestAssistant?.id !== "string")
259
- return false;
260
- if (hasNewerRealUserMessage(db, sessionId, latestAssistant.timeCreated))
261
- return false;
262
- if (latestAssistant.finish === "tool-calls")
263
- return true;
264
- const partRows = db.prepare("SELECT data FROM part WHERE session_id = ? AND message_id = ?").all(sessionId, latestAssistant.id);
265
- return partRows.some((row) => {
266
- if (typeof row.data !== "string" || row.data.length === 0)
267
- return false;
268
- try {
269
- const part = JSON.parse(row.data);
270
- return part.type === "tool" && part.providerExecuted !== true;
271
- } catch {
272
- return false;
273
- }
274
- });
275
- }
276
- function hasNewerRealUserMessage(db, sessionId, latestAssistantTimeCreated) {
277
- if (typeof latestAssistantTimeCreated !== "number")
278
- return false;
279
- const row = db.prepare(`SELECT 1 as one
280
- FROM message
281
- WHERE session_id = ?
282
- AND time_created > ?
283
- AND json_extract(data, '$.role') = 'user'
284
- AND COALESCE(json_extract(data, '$.synthetic'), 0) NOT IN (1, 'true')
285
- LIMIT 1`).get(sessionId, latestAssistantTimeCreated);
286
- return row?.one === 1;
287
- }
288
- function getMessageTimesFromOpenCodeDb(sessionId, messageIds) {
289
- const result = new Map;
290
- if (messageIds.length === 0)
291
- return result;
292
- try {
293
- withReadOnlySessionDb((db) => {
294
- const placeholders = messageIds.map(() => "?").join(",");
295
- const rows = db.prepare(`SELECT id, time_created FROM message WHERE session_id = ? AND id IN (${placeholders})`).all(sessionId, ...messageIds);
296
- for (const row of rows) {
297
- if (typeof row.id === "string" && typeof row.time_created === "number") {
298
- result.set(row.id, row.time_created);
299
- }
300
- }
301
- });
302
- } catch (error) {
303
- log("[magic-context] failed to resolve message times from OpenCode DB:", error);
304
- }
305
- return result;
306
- }
307
- function findLastAssistantModelFromOpenCodeDb(sessionId) {
308
- try {
309
- return withReadOnlySessionDb((db) => {
310
- const row = db.prepare(`SELECT json_extract(data, '$.providerID') as providerID,
311
- json_extract(data, '$.modelID') as modelID,
312
- json_extract(data, '$.agent') as agent
313
- FROM message
314
- WHERE session_id = ?
315
- AND json_extract(data, '$.role') = 'assistant'
316
- AND json_extract(data, '$.providerID') IS NOT NULL
317
- AND json_extract(data, '$.modelID') IS NOT NULL
318
- ORDER BY time_created DESC
319
- LIMIT 1`).get(sessionId);
320
- if (!row || typeof row.providerID !== "string" || typeof row.modelID !== "string") {
321
- return null;
322
- }
323
- const agent = typeof row.agent === "string" && row.agent.length > 0 ? row.agent : undefined;
324
- return {
325
- providerID: row.providerID,
326
- modelID: row.modelID,
327
- ...agent ? { agent } : {}
328
- };
329
- });
330
- } catch (error) {
331
- log("[magic-context] failed to recover live model from OpenCode DB:", error);
332
- return null;
333
- }
334
- }
335
-
336
58
  // src/shared/commit-detection.ts
337
59
  var HASH_HEX = "[0-9a-f]{7,12}";
338
60
  var COMMIT_HASH_TEST_PATTERN = new RegExp(`\\b${HASH_HEX}\\b`, "i");
@@ -133427,6 +133149,27 @@ function setToolContent(part, content) {
133427
133149
  part.content = content;
133428
133150
  }
133429
133151
  }
133152
+ function clonePart(part) {
133153
+ if (part === null || typeof part !== "object")
133154
+ return part;
133155
+ try {
133156
+ return structuredClone(part);
133157
+ } catch {
133158
+ try {
133159
+ return JSON.parse(JSON.stringify(part));
133160
+ } catch {
133161
+ return part;
133162
+ }
133163
+ }
133164
+ }
133165
+ function clampCloneInPlace(occurrence, clamp) {
133166
+ const clone = clonePart(occurrence.part);
133167
+ clamp(clone);
133168
+ const parts = occurrence.message.parts;
133169
+ const index = parts.indexOf(occurrence.part);
133170
+ if (index >= 0)
133171
+ parts[index] = clone;
133172
+ }
133430
133173
  function truncateToolPart(part, tagId) {
133431
133174
  if (!isRecord(part))
133432
133175
  return;
@@ -133548,6 +133291,16 @@ function clearThinkingParts(thinkingParts) {
133548
133291
  part.text = "[cleared]";
133549
133292
  }
133550
133293
  }
133294
+ function partHasCompletedResult(part) {
133295
+ if (!isRecord(part))
133296
+ return false;
133297
+ if (part.type === "tool") {
133298
+ if (!isRecord(part.state))
133299
+ return false;
133300
+ return typeof part.state.output === "string" || part.state.status === "error";
133301
+ }
133302
+ return part.type === "tool_result";
133303
+ }
133551
133304
  function extractToolCallObservation(part) {
133552
133305
  if (!isRecord(part))
133553
133306
  return null;
@@ -133616,7 +133369,7 @@ function createToolDropTarget(compositeKey, thinkingParts, index, batch, tagId)
133616
133369
  if (!entry.hasResult)
133617
133370
  return "incomplete";
133618
133371
  for (const occurrence of entry.occurrences) {
133619
- truncateToolPart(occurrence.part, tagId);
133372
+ clampCloneInPlace(occurrence, (part) => truncateToolPart(part, tagId));
133620
133373
  }
133621
133374
  clearThinkingParts(thinkingParts);
133622
133375
  return "truncated";
@@ -133628,7 +133381,7 @@ function createToolDropTarget(compositeKey, thinkingParts, index, batch, tagId)
133628
133381
  if (!entry.hasResult)
133629
133382
  return "incomplete";
133630
133383
  for (const occurrence of entry.occurrences) {
133631
- editMarkerToolPart(occurrence.part, tagId);
133384
+ clampCloneInPlace(occurrence, (part) => editMarkerToolPart(part, tagId));
133632
133385
  }
133633
133386
  clearThinkingParts(thinkingParts);
133634
133387
  return "truncated";
@@ -135028,4 +134781,4 @@ function clearSession(db, sessionId) {
135028
134781
  })();
135029
134782
  }
135030
134783
 
135031
- export { Database, registerPrivilegedWriter, withPrivilegedWriter, closeQuietly, isRecord, clearCompressionDepth, clearCompressionDepthRange, ensureSessionMetaRow, persistCachedM0, clearCachedM0M1, openCodeDbExists, withReadOnlySessionDb, isMidTurn, getMessageTimesFromOpenCodeDb, findLastAssistantModelFromOpenCodeDb, textMentionsRecentCommit, hasMeaningfulUserText, extractTexts, extractToolCallSummaries, estimateTokens, normalizeText, isRawCompactionSummaryInfo, extractInMemoryMessageViews, buildInMemoryTailRawMessages, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, isTextPart, isToolPartWithOutput, isFilePart, buildFileSourceContent, isEditTool, extractToolCallObservation, ToolMutationBatch, createToolDropTarget, setRawMessageProvider, cleanUserText, withRawSessionMessageCache, readRawSessionMessages, primeTailRawMessageCache, getCachedAbsoluteMessageCount, primeInMemoryTailRawMessageCache, readRawSessionMessageOrdinalPage, getRawSessionStoredMessageCount, readRawSessionMessagePartsById, readRawSessionMessageOrdinalById, readRawSessionMessageById, getRawSessionMessageCount, getRawSessionTagKeysThrough, getLegacyProtectedTailStartOrdinal, readSessionChunk, getMessageIndexSourceIdentity, isMessageIndexSourceCurrent, getLastIndexedOrdinal, getIndexedMessageCorpusSize, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, deleteIndexedMessage, clearIndexedMessages, indexSingleMessage, indexMessagesAfterOrdinal, sweepOrphanedOpenCodeMessageIndexes, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, clearSession };
134784
+ export { textMentionsRecentCommit, hasMeaningfulUserText, extractTexts, extractToolCallSummaries, estimateTokens, normalizeText, clearCompressionDepth, clearCompressionDepthRange, ensureSessionMetaRow, persistCachedM0, clearCachedM0M1, isRawCompactionSummaryInfo, extractInMemoryMessageViews, buildInMemoryTailRawMessages, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, isTextPart, isToolPartWithOutput, isFilePart, buildFileSourceContent, isRecord, isEditTool, partHasCompletedResult, extractToolCallObservation, ToolMutationBatch, createToolDropTarget, setRawMessageProvider, cleanUserText, withRawSessionMessageCache, readRawSessionMessages, primeTailRawMessageCache, getCachedAbsoluteMessageCount, primeInMemoryTailRawMessageCache, readRawSessionMessageOrdinalPage, getRawSessionStoredMessageCount, readRawSessionMessagePartsById, readRawSessionMessageOrdinalById, readRawSessionMessageById, getRawSessionMessageCount, getRawSessionTagKeysThrough, getLegacyProtectedTailStartOrdinal, readSessionChunk, getMessageIndexSourceIdentity, isMessageIndexSourceCurrent, getLastIndexedOrdinal, getIndexedMessageCorpusSize, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, deleteIndexedMessage, clearIndexedMessages, indexSingleMessage, indexMessagesAfterOrdinal, sweepOrphanedOpenCodeMessageIndexes, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, clearSession };
@@ -1,3 +1,6 @@
1
+ import {
2
+ isMidTurn
3
+ } from "./index-fcyvznch.js";
1
4
  import {
2
5
  sessionLog
3
6
  } from "./index-k1esqfwk.js";
@@ -82,6 +85,56 @@ function safeString(value) {
82
85
  }
83
86
 
84
87
  // src/hooks/magic-context/send-session-notification.ts
88
+ var MAX_QUEUED_IGNORED_NOTIFICATIONS = 16;
89
+ var queuedIgnoredNotifications = new Map;
90
+ var flushingIgnoredNotifications = new Set;
91
+ var midTurnDetector = (sessionId) => isMidTurn(undefined, sessionId);
92
+ function queueIgnoredNotification(notification) {
93
+ const queued = queuedIgnoredNotifications.get(notification.sessionId) ?? [];
94
+ queued.push(notification);
95
+ if (queued.length > MAX_QUEUED_IGNORED_NOTIFICATIONS) {
96
+ queued.splice(0, queued.length - MAX_QUEUED_IGNORED_NOTIFICATIONS);
97
+ sessionLog(notification.sessionId, `ignored notification queue full; dropped oldest entries (kept newest ${MAX_QUEUED_IGNORED_NOTIFICATIONS})`);
98
+ }
99
+ queuedIgnoredNotifications.set(notification.sessionId, queued);
100
+ }
101
+ async function trySendTuiToast(sessionId, text, params, forcePersist) {
102
+ if (forcePersist)
103
+ return false;
104
+ const title = extractToastTitle(text);
105
+ const message = text.length > 200 ? `${text.slice(0, 200)}…` : text;
106
+ const toastVariant = inferToastVariant(text);
107
+ const duration = params.toastDurationMs ?? 5000;
108
+ const { isTuiConnected: checkTui } = await import("./rpc-notifications-4d22ybn5.js");
109
+ if (!checkTui(sessionId))
110
+ return false;
111
+ try {
112
+ const { pushNotification } = await import("./rpc-notifications-4d22ybn5.js");
113
+ pushNotification("toast", {
114
+ title,
115
+ message,
116
+ variant: toastVariant,
117
+ duration
118
+ }, sessionId);
119
+ return true;
120
+ } catch {
121
+ sessionLog(sessionId, "TUI RPC toast enqueue failed, falling back to ignored message");
122
+ return false;
123
+ }
124
+ }
125
+ var __ignoredNotificationTest = {
126
+ pendingTexts(sessionId) {
127
+ return (queuedIgnoredNotifications.get(sessionId) ?? []).map((item) => item.text);
128
+ },
129
+ reset() {
130
+ queuedIgnoredNotifications.clear();
131
+ flushingIgnoredNotifications.clear();
132
+ midTurnDetector = (sessionId) => isMidTurn(undefined, sessionId);
133
+ },
134
+ setMidTurnDetector(detector) {
135
+ midTurnDetector = detector;
136
+ }
137
+ };
85
138
  function hasNotificationSessionClient(client) {
86
139
  if (client === null || typeof client !== "object")
87
140
  return false;
@@ -113,31 +166,20 @@ function extractToastTitle(text) {
113
166
  return firstLine;
114
167
  return "Magic Context";
115
168
  }
116
- async function sendIgnoredMessage(client, sessionId, text, params, forcePersist = false) {
117
- const title = extractToastTitle(text);
118
- const message = text.length > 200 ? `${text.slice(0, 200)}…` : text;
119
- const toastVariant = inferToastVariant(text);
120
- const duration = params.toastDurationMs ?? 5000;
121
- const { isTuiConnected: checkTui } = await import("./rpc-notifications-4d22ybn5.js");
122
- if (!forcePersist && checkTui(sessionId)) {
123
- try {
124
- const { pushNotification } = await import("./rpc-notifications-4d22ybn5.js");
125
- pushNotification("toast", {
126
- title,
127
- message,
128
- variant: toastVariant,
129
- duration
130
- }, sessionId);
131
- return "sent";
132
- } catch {
133
- sessionLog(sessionId, "TUI RPC toast enqueue failed, falling back to ignored message");
134
- }
169
+ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersist) {
170
+ if (midTurnDetector(sessionId)) {
171
+ queueIgnoredNotification({ client, sessionId, text, params, forcePersist });
172
+ return "queued";
135
173
  }
136
174
  const { waitForSafeNotificationTarget } = await import("./safe-notification-target-q9jk5n44.js");
137
175
  if (await waitForSafeNotificationTarget(client, sessionId) === "skip") {
138
176
  sessionLog(sessionId, "notification skipped (session not titled yet)");
139
177
  return "skipped";
140
178
  }
179
+ if (midTurnDetector(sessionId)) {
180
+ queueIgnoredNotification({ client, sessionId, text, params, forcePersist });
181
+ return "queued";
182
+ }
141
183
  if (!hasNotificationSessionClient(client)) {
142
184
  sessionLog(sessionId, "session prompt API unavailable for notification");
143
185
  return "failed";
@@ -157,6 +199,10 @@ async function sendIgnoredMessage(client, sessionId, text, params, forcePersist
157
199
  }
158
200
  } catch {}
159
201
  }
202
+ if (midTurnDetector(sessionId)) {
203
+ queueIgnoredNotification({ client, sessionId, text, params, forcePersist });
204
+ return "queued";
205
+ }
160
206
  const input = {
161
207
  path: { id: sessionId },
162
208
  body: {
@@ -190,6 +236,41 @@ async function sendIgnoredMessage(client, sessionId, text, params, forcePersist
190
236
  return "failed";
191
237
  }
192
238
  }
239
+ async function sendIgnoredMessage(client, sessionId, text, params, forcePersist = false) {
240
+ if (await trySendTuiToast(sessionId, text, params, forcePersist))
241
+ return "sent";
242
+ if (midTurnDetector(sessionId)) {
243
+ queueIgnoredNotification({ client, sessionId, text, params, forcePersist });
244
+ return "queued";
245
+ }
246
+ return sendIgnoredMessageNow(client, sessionId, text, params, forcePersist);
247
+ }
248
+ async function flushIgnoredMessages(sessionId) {
249
+ if (flushingIgnoredNotifications.has(sessionId) || midTurnDetector(sessionId))
250
+ return;
251
+ const queued = queuedIgnoredNotifications.get(sessionId);
252
+ if (!queued || queued.length === 0)
253
+ return;
254
+ queuedIgnoredNotifications.delete(sessionId);
255
+ flushingIgnoredNotifications.add(sessionId);
256
+ try {
257
+ for (const notification of queued) {
258
+ const disposition = await sendIgnoredMessage(notification.client, notification.sessionId, notification.text, notification.params, notification.forcePersist);
259
+ if (disposition === "queued") {
260
+ for (const remaining of queued.slice(queued.indexOf(notification) + 1)) {
261
+ queueIgnoredNotification(remaining);
262
+ }
263
+ break;
264
+ }
265
+ }
266
+ } finally {
267
+ flushingIgnoredNotifications.delete(sessionId);
268
+ }
269
+ }
270
+ function clearIgnoredMessages(sessionId) {
271
+ queuedIgnoredNotifications.delete(sessionId);
272
+ flushingIgnoredNotifications.delete(sessionId);
273
+ }
193
274
  async function sendUserPrompt(client, sessionId, text) {
194
275
  if (!hasNotificationSessionClient(client)) {
195
276
  sessionLog(sessionId, "session prompt API unavailable for user prompt");
@@ -216,4 +297,4 @@ async function sendUserPrompt(client, sessionId, text) {
216
297
  }
217
298
  }
218
299
 
219
- export { getErrorMessage, describeError, sendIgnoredMessage, sendUserPrompt };
300
+ export { getErrorMessage, describeError, MAX_QUEUED_IGNORED_NOTIFICATIONS, __ignoredNotificationTest, sendIgnoredMessage, flushIgnoredMessages, clearIgnoredMessages, sendUserPrompt };
@@ -10,10 +10,11 @@ import {
10
10
 
11
11
  // src/plugin/conflict-warning-hook.ts
12
12
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
13
- import { homedir as homedir2, platform } from "node:os";
13
+ import { homedir as homedir3, platform } from "node:os";
14
14
  import { join as join3 } from "node:path";
15
15
 
16
16
  // src/shared/conflict-detector.ts
17
+ import { homedir as homedir2 } from "node:os";
17
18
  import { join as join2 } from "node:path";
18
19
 
19
20
  // src/shared/jsonc-parser.ts
@@ -159,7 +160,8 @@ function getOpenCodeConfigPaths(options) {
159
160
  }
160
161
 
161
162
  // src/shared/conflict-detector.ts
162
- function detectConflicts(directory) {
163
+ function detectConflicts(directory, options) {
164
+ const compactionEnabled = options?.compactionEnabled ?? true;
163
165
  const conflicts = {
164
166
  compactionAuto: false,
165
167
  compactionPrune: false,
@@ -170,11 +172,11 @@ function detectConflicts(directory) {
170
172
  };
171
173
  const reasons = [];
172
174
  const compactionResult = checkCompaction(directory);
173
- if (compactionResult.auto) {
175
+ if (compactionEnabled && compactionResult.auto) {
174
176
  conflicts.compactionAuto = true;
175
177
  reasons.push("OpenCode auto-compaction is enabled (compaction.auto=true)");
176
178
  }
177
- if (compactionResult.prune) {
179
+ if (compactionEnabled && compactionResult.prune) {
178
180
  conflicts.compactionPrune = true;
179
181
  reasons.push("OpenCode prune is enabled (compaction.prune=true)");
180
182
  }
@@ -199,7 +201,8 @@ function detectConflicts(directory) {
199
201
  return {
200
202
  hasConflict: reasons.length > 0,
201
203
  reasons,
202
- conflicts
204
+ conflicts,
205
+ nativeCompaction: { auto: compactionResult.auto, prune: compactionResult.prune }
203
206
  };
204
207
  }
205
208
  function checkCompaction(directory) {
@@ -342,6 +345,24 @@ function readOmoDisabledHooks(directory) {
342
345
  }
343
346
  }
344
347
  }
348
+ const homeDir = process.env.HOME || homedir2();
349
+ const omoHomeDir = join2(homeDir, ".omo");
350
+ for (const name of ["omo.jsonc", "omo.json"]) {
351
+ const config = readJsoncFile(join2(omoHomeDir, name));
352
+ if (config?.["[opencode]"]?.disabled_hooks) {
353
+ for (const hook of config["[opencode]"].disabled_hooks) {
354
+ disabled.add(hook);
355
+ }
356
+ }
357
+ }
358
+ for (const name of ["omo.jsonc", "omo.json"]) {
359
+ const config = readJsoncFile(join2(directory, ".omo", name));
360
+ if (config?.["[opencode]"]?.disabled_hooks) {
361
+ for (const hook of config["[opencode]"].disabled_hooks) {
362
+ disabled.add(hook);
363
+ }
364
+ }
365
+ }
345
366
  return disabled;
346
367
  }
347
368
  function formatConflictShort(result) {
@@ -365,7 +386,7 @@ var ENABLED_MARKER = "✨ Magic Context is now enabled";
365
386
  var ANNOUNCEMENT_MARKER = "✨ Magic Context — what's new in";
366
387
  function getDesktopStatePath() {
367
388
  const os = platform();
368
- const home = homedir2();
389
+ const home = homedir3();
369
390
  if (os === "darwin") {
370
391
  return join3(home, "Library", "Application Support", "ai.opencode.desktop", "opencode.global.dat");
371
392
  }