@cortexkit/opencode-magic-context 0.42.5 → 0.42.6

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 (128) hide show
  1. package/README.md +2 -2
  2. package/dist/config/index.d.ts +9 -0
  3. package/dist/config/index.d.ts.map +1 -1
  4. package/dist/config/schema/magic-context.d.ts +1 -0
  5. package/dist/config/schema/magic-context.d.ts.map +1 -1
  6. package/dist/{conflict-warning-hook-jyj54gbe.js → conflict-warning-hook-aktepwpz.js} +3 -3
  7. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  8. package/dist/features/magic-context/context-authority.d.ts +28 -1
  9. package/dist/features/magic-context/context-authority.d.ts.map +1 -1
  10. package/dist/features/magic-context/dreamer/open-opencode-db.d.ts.map +1 -1
  11. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  12. package/dist/features/magic-context/memory/embedding-local.d.ts +1 -0
  13. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  14. package/dist/features/magic-context/memory/embedding.d.ts +1 -1
  15. package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
  16. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  17. package/dist/features/magic-context/migrations.d.ts +12 -0
  18. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  19. package/dist/features/magic-context/project-embedding-registry.d.ts +1 -0
  20. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  21. package/dist/features/magic-context/session-project-backfill.d.ts.map +1 -1
  22. package/dist/features/magic-context/storage-db.d.ts +1 -1
  23. package/dist/features/magic-context/tool-owner-backfill.d.ts.map +1 -1
  24. package/dist/hooks/auto-update-checker/index.d.ts.map +1 -1
  25. package/dist/hooks/magic-context/cache-busting-signals.d.ts +0 -1
  26. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
  27. package/dist/hooks/magic-context/channel2-delivery.d.ts +8 -0
  28. package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
  29. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +12 -0
  30. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  31. package/dist/hooks/magic-context/hook.d.ts +4 -4
  32. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  33. package/dist/hooks/magic-context/module-state-sync.d.ts +3 -0
  34. package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
  35. package/dist/hooks/magic-context/module-transport.d.ts +24 -2
  36. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/module-wire.d.ts +1 -1
  38. package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/producer-window-guard.d.ts +31 -1
  40. package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
  41. package/dist/hooks/magic-context/read-session-chunk.d.ts +6 -0
  42. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  43. package/dist/hooks/magic-context/read-session-db.d.ts +8 -0
  44. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/read-session-formatting.d.ts +6 -0
  46. package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
  47. package/dist/hooks/magic-context/rust-mode-transform.d.ts +30 -0
  48. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  49. package/dist/hooks/magic-context/rust-refusal-recovery.d.ts +28 -0
  50. package/dist/hooks/magic-context/rust-refusal-recovery.d.ts.map +1 -0
  51. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  52. package/dist/hooks/magic-context/transform.d.ts +7 -0
  53. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  54. package/dist/{index-jkrqhc7y.js → index-a9ssj59b.js} +94 -15
  55. package/dist/{index-3wbd8sdq.js → index-djp6rwz6.js} +455 -46
  56. package/dist/{index-p474rw9p.js → index-ngjmj6xx.js} +1 -1
  57. package/dist/{index-d8mgqezq.js → index-s61hh7gv.js} +50 -17
  58. package/dist/{index-1ar7b3e9.js → index-znraa0kv.js} +1 -1
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +1485 -360
  61. package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
  62. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  63. package/dist/plugin/memory-id-translation.d.ts +23 -0
  64. package/dist/plugin/memory-id-translation.d.ts.map +1 -0
  65. package/dist/plugin/rust-tool-backends.d.ts +1 -1
  66. package/dist/plugin/rust-tool-backends.d.ts.map +1 -1
  67. package/dist/{recomp-orchestrator-k20sfpm2.js → recomp-orchestrator-0xx1364v.js} +4 -4
  68. package/dist/{send-session-notification-xnypkxpx.js → send-session-notification-jbxknvar.js} +2 -2
  69. package/dist/shared/auto-update-provenance.d.ts +9 -0
  70. package/dist/shared/auto-update-provenance.d.ts.map +1 -0
  71. package/dist/shared/conflict-detector.d.ts +5 -1
  72. package/dist/shared/conflict-detector.d.ts.map +1 -1
  73. package/dist/shared/opencode-db-path.d.ts +31 -2
  74. package/dist/shared/opencode-db-path.d.ts.map +1 -1
  75. package/dist/shared/prompt-surface-runtime.d.ts +3 -3
  76. package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
  77. package/dist/{storage-meta-session-x3j0q9qy.js → storage-meta-session-z818pn1e.js} +2 -2
  78. package/dist/tools/ctx-expand/mode.d.ts +31 -0
  79. package/dist/tools/ctx-expand/mode.d.ts.map +1 -0
  80. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  81. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  82. package/dist/tools/ctx-note/constants.d.ts +1 -1
  83. package/dist/tools/ctx-note/constants.d.ts.map +1 -1
  84. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  85. package/dist/tools/ctx-note/types.d.ts +1 -1
  86. package/dist/tools/ctx-note/types.d.ts.map +1 -1
  87. package/dist/tools/ctx-reduce/constants.d.ts +1 -1
  88. package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
  89. package/dist/tools/ctx-search/types.d.ts +1 -1
  90. package/dist/tools/ctx-search/types.d.ts.map +1 -1
  91. package/dist/tools/light-descriptions.d.ts +2 -2
  92. package/dist/tools/light-descriptions.d.ts.map +1 -1
  93. package/dist/v2/hidden-completion.d.ts +69 -13
  94. package/dist/v2/hidden-completion.d.ts.map +1 -1
  95. package/dist/v2/hooks/context.d.ts +13 -1
  96. package/dist/v2/hooks/context.d.ts.map +1 -1
  97. package/dist/v2/hooks/hidden-child.d.ts +31 -0
  98. package/dist/v2/hooks/hidden-child.d.ts.map +1 -0
  99. package/dist/v2/hooks/store.d.ts.map +1 -1
  100. package/dist/v2/hooks/types.d.ts +99 -19
  101. package/dist/v2/hooks/types.d.ts.map +1 -1
  102. package/dist/v2/server.d.ts +19 -0
  103. package/dist/v2/server.d.ts.map +1 -1
  104. package/dist/v2/server.js +1781 -253
  105. package/dist/v2/store-reader.d.ts +11 -5
  106. package/dist/v2/store-reader.d.ts.map +1 -1
  107. package/dist/v2/tui/index.d.ts +10 -0
  108. package/dist/v2/tui/index.d.ts.map +1 -0
  109. package/dist/v2/tui/types.d.ts +80 -0
  110. package/dist/v2/tui/types.d.ts.map +1 -0
  111. package/package.json +5 -4
  112. package/src/agents/magic-context-prompt.ts +1 -1
  113. package/src/config/index.ts +31 -1
  114. package/src/config/protected-tokens.test.ts +40 -0
  115. package/src/config/schema/magic-context.ts +8 -3
  116. package/src/shared/auto-update-provenance.ts +42 -0
  117. package/src/shared/conflict-detector.test.ts +53 -0
  118. package/src/shared/conflict-detector.ts +88 -19
  119. package/src/shared/models-dev-cache.test.ts +25 -0
  120. package/src/shared/opencode-db-path.test.ts +96 -0
  121. package/src/shared/opencode-db-path.ts +146 -15
  122. package/src/shared/prompt-surface-a1-golden.md +12 -16
  123. package/src/shared/prompt-surface-runtime.test.ts +20 -0
  124. package/src/shared/prompt-surface-runtime.ts +7 -5
  125. package/src/tui/entry.mjs +11 -1
  126. package/src/v2/tui/host-contract.test.ts +202 -0
  127. package/src/v2/tui/index.ts +270 -0
  128. package/src/v2/tui/types.ts +67 -0
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-qp20p2py.js";
4
4
  import {
5
5
  shouldHoldIgnoredNotification
6
- } from "./index-jkrqhc7y.js";
6
+ } from "./index-a9ssj59b.js";
7
7
 
8
8
  // src/shared/error-message.ts
9
9
  function getErrorMessage(error) {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-qp20p2py.js";
4
4
  import {
5
5
  sendStatusNotification2
6
- } from "./index-p474rw9p.js";
6
+ } from "./index-ngjmj6xx.js";
7
7
  import {
8
8
  readJsoncFile
9
9
  } from "./index-sd3egckz.js";
@@ -47,6 +47,7 @@ function getOpenCodeConfigPaths(options) {
47
47
  // src/shared/conflict-detector.ts
48
48
  function detectConflicts(directory, options) {
49
49
  const compactionEnabled = options?.compactionEnabled ?? true;
50
+ const hostGeneration = options?.hostGeneration ?? "v1";
50
51
  const conflicts = {
51
52
  compactionAuto: false,
52
53
  compactionPrune: false,
@@ -56,15 +57,15 @@ function detectConflicts(directory, options) {
56
57
  omoAnthropicRecovery: false
57
58
  };
58
59
  const reasons = [];
59
- let compactionResult = options?.resolvedCompaction ?? checkCompaction(directory);
60
+ let compactionResult = options?.resolvedCompaction ?? checkCompaction(directory, hostGeneration);
60
61
  if (process.env.OPENCODE_DISABLE_AUTOCOMPACT) {
61
62
  compactionResult = { auto: false, prune: false };
62
63
  }
63
- if (compactionEnabled && compactionResult.auto) {
64
+ if (hostGeneration === "v1" && compactionEnabled && compactionResult.auto) {
64
65
  conflicts.compactionAuto = true;
65
66
  reasons.push(options?.resolvedCompaction ? "OpenCode auto-compaction is enabled (compaction.auto=true) (resolved config)" : "OpenCode auto-compaction is enabled (compaction.auto=true)");
66
67
  }
67
- if (compactionEnabled && compactionResult.prune) {
68
+ if (hostGeneration === "v1" && compactionEnabled && compactionResult.prune) {
68
69
  conflicts.compactionPrune = true;
69
70
  reasons.push(options?.resolvedCompaction ? "OpenCode prune is enabled (compaction.prune=true) (resolved config)" : "OpenCode prune is enabled (compaction.prune=true)");
70
71
  }
@@ -90,10 +91,13 @@ function detectConflicts(directory, options) {
90
91
  hasConflict: reasons.length > 0,
91
92
  reasons,
92
93
  conflicts,
93
- nativeCompaction: { auto: compactionResult.auto, prune: compactionResult.prune }
94
+ nativeCompaction: {
95
+ auto: compactionResult.auto,
96
+ prune: hostGeneration === "v1" ? compactionResult.prune : false
97
+ }
94
98
  };
95
99
  }
96
- async function resolveCompactionForBoot(client, timeoutMs = 2000) {
100
+ async function resolveCompactionForBoot(client, timeoutMs = 2000, hostGeneration = "v1") {
97
101
  const controller = new AbortController;
98
102
  let timer;
99
103
  try {
@@ -109,6 +113,23 @@ async function resolveCompactionForBoot(client, timeoutMs = 2000) {
109
113
  if (result === null)
110
114
  return null;
111
115
  const compaction = result?.data?.compaction;
116
+ if (hostGeneration === "v2") {
117
+ if (typeof compaction?.auto !== "boolean") {
118
+ log(`[magic-context] conflict-detector: resolved v2 config carried no explicit compaction.auto (${JSON.stringify(compaction) ?? "absent"}); falling back to file-based detection`);
119
+ return null;
120
+ }
121
+ const keepTokens = compaction.keep?.tokens;
122
+ const buffer = compaction.buffer;
123
+ if (keepTokens !== undefined && (!Number.isInteger(keepTokens) || keepTokens < 0) || buffer !== undefined && (!Number.isInteger(buffer) || buffer < 0)) {
124
+ return null;
125
+ }
126
+ return {
127
+ auto: compaction.auto,
128
+ prune: false,
129
+ ...keepTokens === undefined ? {} : { keepTokens },
130
+ ...buffer === undefined ? {} : { buffer }
131
+ };
132
+ }
112
133
  if (typeof compaction?.auto !== "boolean" || typeof compaction?.prune !== "boolean") {
113
134
  log(`[magic-context] conflict-detector: resolved config carried no explicit compaction block (${JSON.stringify(compaction) ?? "absent"}); falling back to file-based detection`);
114
135
  return null;
@@ -121,26 +142,26 @@ async function resolveCompactionForBoot(client, timeoutMs = 2000) {
121
142
  clearTimeout(timer);
122
143
  }
123
144
  }
124
- function checkCompaction(directory) {
145
+ function checkCompaction(directory, hostGeneration) {
125
146
  if (process.env.OPENCODE_DISABLE_AUTOCOMPACT) {
126
147
  return { auto: false, prune: false };
127
148
  }
128
- const projectResult = readProjectCompaction(directory);
149
+ const projectResult = readProjectCompaction(directory, hostGeneration);
129
150
  if (projectResult.resolved)
130
151
  return projectResult;
131
- const userResult = readUserCompaction();
152
+ const userResult = readUserCompaction(hostGeneration);
132
153
  if (userResult.resolved)
133
154
  return userResult;
134
155
  return { auto: true, prune: false };
135
156
  }
136
- function readProjectCompaction(directory) {
157
+ function readProjectCompaction(directory, hostGeneration) {
137
158
  const dotOcJsonc = join2(directory, ".opencode", "opencode.jsonc");
138
159
  const dotOcJson = join2(directory, ".opencode", "opencode.json");
139
160
  const dotOcConfig = readJsoncFile(dotOcJsonc) ?? readJsoncFile(dotOcJson);
140
161
  if (dotOcConfig?.compaction) {
141
162
  const c = dotOcConfig.compaction;
142
- if (c.auto !== undefined || c.prune !== undefined) {
143
- return { auto: c.auto === true, prune: c.prune === true, resolved: true };
163
+ if (c.auto !== undefined || hostGeneration === "v1" && c.prune !== undefined || hostGeneration === "v2" && (c.keep?.tokens !== undefined || c.buffer !== undefined)) {
164
+ return resolvedCompactionBlock(c, hostGeneration);
144
165
  }
145
166
  }
146
167
  const rootJsonc = join2(directory, "opencode.jsonc");
@@ -148,25 +169,37 @@ function readProjectCompaction(directory) {
148
169
  const rootConfig = readJsoncFile(rootJsonc) ?? readJsoncFile(rootJson);
149
170
  if (rootConfig?.compaction) {
150
171
  const c = rootConfig.compaction;
151
- if (c.auto !== undefined || c.prune !== undefined) {
152
- return { auto: c.auto === true, prune: c.prune === true, resolved: true };
172
+ if (c.auto !== undefined || hostGeneration === "v1" && c.prune !== undefined || hostGeneration === "v2" && (c.keep?.tokens !== undefined || c.buffer !== undefined)) {
173
+ return resolvedCompactionBlock(c, hostGeneration);
153
174
  }
154
175
  }
155
176
  return { auto: false, prune: false, resolved: false };
156
177
  }
157
- function readUserCompaction() {
178
+ function readUserCompaction(hostGeneration) {
158
179
  try {
159
180
  const paths = getOpenCodeConfigPaths({ binary: "opencode" });
160
181
  const config = readJsoncFile(paths.configJsonc) ?? readJsoncFile(paths.configJson);
161
182
  if (config?.compaction) {
162
183
  const c = config.compaction;
163
- if (c.auto !== undefined || c.prune !== undefined) {
164
- return { auto: c.auto === true, prune: c.prune === true, resolved: true };
184
+ if (c.auto !== undefined || hostGeneration === "v1" && c.prune !== undefined || hostGeneration === "v2" && (c.keep?.tokens !== undefined || c.buffer !== undefined)) {
185
+ return resolvedCompactionBlock(c, hostGeneration);
165
186
  }
166
187
  }
167
188
  } catch {}
168
189
  return { auto: false, prune: false, resolved: false };
169
190
  }
191
+ function resolvedCompactionBlock(block, hostGeneration) {
192
+ if (hostGeneration === "v2") {
193
+ return {
194
+ auto: block.auto !== false,
195
+ prune: false,
196
+ resolved: true,
197
+ ...typeof block.keep?.tokens === "number" ? { keepTokens: block.keep.tokens } : {},
198
+ ...typeof block.buffer === "number" ? { buffer: block.buffer } : {}
199
+ };
200
+ }
201
+ return { auto: block.auto === true, prune: block.prune === true, resolved: true };
202
+ }
170
203
  var DCP_PACKAGE_NAMES = new Set(["@tarquinen/opencode-dcp"]);
171
204
  function checkDcpPlugin(directory) {
172
205
  const plugins = collectPluginEntries(directory);
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-qp20p2py.js";
4
4
  import {
5
5
  withReadOnlySessionDb
6
- } from "./index-jkrqhc7y.js";
6
+ } from "./index-a9ssj59b.js";
7
7
  import {
8
8
  piModelRefToCanonical
9
9
  } from "./index-avwt563y.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA4FvE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAq6BpC,QAAA,MAAM,MAAM,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAIjD,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA6FvE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AA46BpC,QAAA,MAAM,MAAM,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAIjD,CAAC;AAEF,eAAe,MAAM,CAAC"}