@cortexkit/opencode-magic-context 0.49.37 → 0.49.39

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 (47) hide show
  1. package/dist/auto-search-worker.js +1 -1
  2. package/dist/{context-ngk2jz60.js → context-na1w4gqp.js} +9 -9
  3. package/dist/features/magic-context/auto-search-diagnostics.d.ts +3 -1
  4. package/dist/features/magic-context/auto-search-diagnostics.d.ts.map +1 -1
  5. package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
  6. package/dist/features/magic-context/search.d.ts.map +1 -1
  7. package/dist/{index-2rs7912w.js → index-9z4d2ha0.js} +34 -1
  8. package/dist/{index-gnmhbyyc.js → index-gfd41hm4.js} +10 -10
  9. package/dist/{index-dz48h1wx.js → index-hb76vdmm.js} +11 -5
  10. package/dist/{index-dfdg2cgg.js → index-hf771sk4.js} +7 -7
  11. package/dist/{index-wcwhhtdh.js → index-j5qma52p.js} +13 -16
  12. package/dist/{index-ys7j6679.js → index-m8v7nqgp.js} +1 -1
  13. package/dist/{index-4ks89h5a.js → index-ryz4pdvf.js} +1 -1
  14. package/dist/{index-9tdvbdv1.js → index-tr6vcwt0.js} +1 -1
  15. package/dist/{index-pp8vdn01.js → index-wk7x13qv.js} +2 -2
  16. package/dist/{index-prw8apnc.js → index-z7etaphs.js} +2 -2
  17. package/dist/index.js +13 -13
  18. package/dist/{message-index-bounded-wfk6aqxk.js → message-index-bounded-jqm3ezva.js} +1 -1
  19. package/dist/raw-ordinal-warmup-worker.js +3 -3
  20. package/dist/{recomp-orchestrator-wk509qkp.js → recomp-orchestrator-34mh19vm.js} +3 -3
  21. package/dist/{render-h1qarr8a.js → render-gqdq6t7f.js} +1 -1
  22. package/dist/{search-archive-q79hyqxs.js → search-archive-kfwpk73t.js} +2 -2
  23. package/dist/{search-5h9fydyq.js → search-vqkmmy9c.js} +3 -3
  24. package/dist/shared/search-text.d.ts +2 -0
  25. package/dist/shared/search-text.d.ts.map +1 -1
  26. package/dist/{transform-postprocess-phase-4gj0mtcg.js → transform-postprocess-phase-61f7t9xq.js} +4 -4
  27. package/dist/v2/auto-search-worker.js +1 -1
  28. package/dist/v2/{context-05x7kr7f.js → context-ejyvb9kp.js} +7 -7
  29. package/dist/v2/{message-index-bounded-w14496s9.js → message-index-bounded-dgd8a2x1.js} +1 -1
  30. package/dist/v2/raw-ordinal-warmup-worker.js +3 -3
  31. package/dist/v2/{recomp-orchestrator-9cjk6aej.js → recomp-orchestrator-x0r6sy3a.js} +2 -2
  32. package/dist/v2/{render-5dz1knf2.js → render-yyv8nv4p.js} +1 -1
  33. package/dist/v2/{search-archive-z6z9jqwf.js → search-archive-gagdnrb3.js} +2 -2
  34. package/dist/v2/{search-8yfet25y.js → search-cb1kdgqw.js} +2 -2
  35. package/dist/v2/{server-a9w5f0yw.js → server-2d01821b.js} +1 -1
  36. package/dist/v2/{server-e51xmr4d.js → server-2tp6y1qs.js} +2 -2
  37. package/dist/v2/{server-5by3vdzs.js → server-405ap0b0.js} +1 -1
  38. package/dist/v2/{server-dfq5vb8j.js → server-dt9b00ja.js} +34 -1
  39. package/dist/v2/{server-7094pk3w.js → server-r4mmc670.js} +15 -13
  40. package/dist/v2/server.js +2 -2
  41. package/dist/v2/{v2-archive-reader-z7wr42ry.js → v2-archive-reader-2rv5dz7k.js} +1 -1
  42. package/dist/v2/{wrapup-orchestrator-j1v62bkj.js → wrapup-orchestrator-f8w3kcjf.js} +2 -2
  43. package/dist/{v2-archive-reader-028z6kck.js → v2-archive-reader-4hz9pnmy.js} +1 -1
  44. package/dist/{wrapup-orchestrator-xg9avt2p.js → wrapup-orchestrator-7dxwer1p.js} +4 -4
  45. package/package.json +1 -1
  46. package/src/shared/search-text.test.ts +36 -1
  47. package/src/shared/search-text.ts +48 -0
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  renderSearchArchive2,
3
3
  renderSearchArchiveOffThread2
4
- } from "./index-4ks89h5a.js";
5
- import"./index-prw8apnc.js";
4
+ } from "./index-ryz4pdvf.js";
5
+ import"./index-z7etaphs.js";
6
6
  import"./index-kaqs6h31.js";
7
7
  import"./index-tn9drm1a.js";
8
8
  import"./index-8jjjmhab.js";
@@ -5,8 +5,8 @@ import {
5
5
  resolveMemoriesByIdsForSearch2,
6
6
  unifiedSearch2,
7
7
  formatSearchResults2
8
- } from "./index-wcwhhtdh.js";
9
- import"./index-dz48h1wx.js";
8
+ } from "./index-j5qma52p.js";
9
+ import"./index-hb76vdmm.js";
10
10
  import"./index-kaqs6h31.js";
11
11
  import"./index-xnm0wq1r.js";
12
12
  import"./index-ty4vhe4n.js";
@@ -14,7 +14,7 @@ import"./index-jjvbk92s.js";
14
14
  import"./index-21fgrfrf.js";
15
15
  import"./index-4dhv7mqz.js";
16
16
  import"./index-2qbtqg1w.js";
17
- import"./index-2rs7912w.js";
17
+ import"./index-9z4d2ha0.js";
18
18
  import"./index-2amn2s73.js";
19
19
  import"./index-qt1qqasc.js";
20
20
  import"./index-tn9drm1a.js";
@@ -3,6 +3,8 @@ export declare function removeTaskNotifications(text: string): string;
3
3
  export declare function cleanSearchText(text: string): string;
4
4
  /** Score the share of distinct query terms present, independently of other results. */
5
5
  export declare function keywordRelevance(query: string, content: string): number;
6
+ /** Match unspaced clauses for hints without changing retrieval or snippet scoring. */
7
+ export declare function hintKeywordRelevance(query: string, content: string): number;
6
8
  /** Pick the densest matching passage before compression can discard the matched words. */
7
9
  export declare function matchedSearchSnippet(content: string, query: string, cap?: number): string;
8
10
  //# sourceMappingURL=search-text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search-text.d.ts","sourceRoot":"","sources":["../../src/shared/search-text.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,0GAA0G;AAC1G,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIpD;AAkBD,uFAAuF;AACvF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKvE;AAED,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAM,GAAG,MAAM,CAwBtF"}
1
+ {"version":3,"file":"search-text.d.ts","sourceRoot":"","sources":["../../src/shared/search-text.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,0GAA0G;AAC1G,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIpD;AAkBD,uFAAuF;AACvF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKvE;AAsBD,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAyB3E;AAED,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAM,GAAG,MAAM,CAwBtF"}
@@ -19,9 +19,9 @@ import {
19
19
  finalizeMessageRepresentation2,
20
20
  runPostTransformPhase2,
21
21
  checkM0MutationDriftAndSignal2
22
- } from "./index-dfdg2cgg.js";
23
- import"./index-dz48h1wx.js";
24
- import"./index-9tdvbdv1.js";
22
+ } from "./index-hf771sk4.js";
23
+ import"./index-hb76vdmm.js";
24
+ import"./index-tr6vcwt0.js";
25
25
  import"./index-850vthn3.js";
26
26
  import"./index-sd3egckz.js";
27
27
  import"./index-xnm0wq1r.js";
@@ -31,7 +31,7 @@ import"./index-21fgrfrf.js";
31
31
  import"./index-4dhv7mqz.js";
32
32
  import"./index-72czy45z.js";
33
33
  import"./index-2qbtqg1w.js";
34
- import"./index-2rs7912w.js";
34
+ import"./index-9z4d2ha0.js";
35
35
  import"./index-2amn2s73.js";
36
36
  import"./index-66a50f3e.js";
37
37
  import"./index-dnqqqc5f.js";
@@ -31,7 +31,7 @@ serveWorkerJobs(async (initial, port) => {
31
31
  import("./embedding-cache-mgyr73ef.js"),
32
32
  import("./storage-memory-e6a7mb0k.js"),
33
33
  import("./project-embedding-registry-jqq2qeqb.js"),
34
- import("./search-8yfet25y.js"),
34
+ import("./search-cb1kdgqw.js"),
35
35
  import("./compartment-chunk-embedding-qfk791bd.js"),
36
36
  import("./embedding-activity-g1dhes6g.js"),
37
37
  import("./harness-e4avh192.js"),
@@ -209,7 +209,7 @@ import {
209
209
  startCompartmentAgent,
210
210
  setRecompStarting2,
211
211
  setRecompTerminal2
212
- } from "./server-5by3vdzs.js";
212
+ } from "./server-405ap0b0.js";
213
213
  import {
214
214
  resolveHistorianModel2
215
215
  } from "./server-5kym00ag.js";
@@ -601,7 +601,7 @@ import {
601
601
  cleanSearchText,
602
602
  matchedSearchSnippet,
603
603
  getLastIndexedOrdinal
604
- } from "./server-dfq5vb8j.js";
604
+ } from "./server-dt9b00ja.js";
605
605
  import"./server-nmyganc8.js";
606
606
  import {
607
607
  getMessageIndexEpoch,
@@ -628,7 +628,7 @@ import {
628
628
  resolveMemoriesByIdsForSearch2,
629
629
  unifiedSearch2,
630
630
  formatSearchResults2
631
- } from "./server-7094pk3w.js";
631
+ } from "./server-r4mmc670.js";
632
632
  import {
633
633
  embedPauseBySession,
634
634
  embedRunStateBySession,
@@ -966,10 +966,10 @@ import {
966
966
  import"./server-kaqs6h31.js";
967
967
  import {
968
968
  readV2ArchiveOffThread2
969
- } from "./server-e51xmr4d.js";
969
+ } from "./server-2tp6y1qs.js";
970
970
  import {
971
971
  renderSearchArchiveOffThread2
972
- } from "./server-a9w5f0yw.js";
972
+ } from "./server-2d01821b.js";
973
973
  import {
974
974
  markCoveredInstructionRow,
975
975
  isCoveredInstructionRow,
@@ -24320,7 +24320,7 @@ function registerRpcHandlers(rpcServer, args) {
24320
24320
  const db = readDatabase();
24321
24321
  if (!db)
24322
24322
  return { ok: false, error: "db unavailable" };
24323
- const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-9cjk6aej.js"));
24323
+ const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-x0r6sy3a.js"));
24324
24324
  const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-kxp47tsw.js"));
24325
24325
  log2(`[rpc] recomp requested for session ${sessionId}`);
24326
24326
  if (!args.client && !args.hiddenCompletionExecutor) {
@@ -24405,7 +24405,7 @@ function registerRpcHandlers(rpcServer, args) {
24405
24405
  const db = readDatabase();
24406
24406
  if (!db)
24407
24407
  return { ok: false, error: "db unavailable" };
24408
- const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-j1v62bkj.js"));
24408
+ const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-f8w3kcjf.js"));
24409
24409
  const model = liveSessionState.liveModelBySession.get(sessionId);
24410
24410
  const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
24411
24411
  const ctx = {
@@ -26,7 +26,7 @@ import {
26
26
  markMessageIndexDirty,
27
27
  getIndexableContent,
28
28
  indexSingleMessage
29
- } from "./server-dfq5vb8j.js";
29
+ } from "./server-dt9b00ja.js";
30
30
  import"./server-nmyganc8.js";
31
31
  import"./server-qmmkhz2z.js";
32
32
 
@@ -19,7 +19,7 @@ serveWorkerJobs(async (input, port) => {
19
19
  await main();
20
20
  async function main() {
21
21
  if (input.v2ArchiveReader) {
22
- const { serveV2ArchiveReads } = await import("./v2-archive-reader-z7wr42ry.js");
22
+ const { serveV2ArchiveReads } = await import("./v2-archive-reader-2rv5dz7k.js");
23
23
  await serveV2ArchiveReads(port, openConnections);
24
24
  return;
25
25
  }
@@ -51,7 +51,7 @@ serveWorkerJobs(async (input, port) => {
51
51
  await runMessageFtsRowidMapBackfill(db);
52
52
  reply = { kind: "fts-rowid-backfill" };
53
53
  } else if (input.searchArchive) {
54
- const { renderSearchArchive } = await import("./search-archive-z6z9jqwf.js");
54
+ const { renderSearchArchive } = await import("./search-archive-gagdnrb3.js");
55
55
  const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-qpp6x9kg.js");
56
56
  const archive = input.searchArchive;
57
57
  let raw;
@@ -81,7 +81,7 @@ serveWorkerJobs(async (input, port) => {
81
81
  const { setHarness } = await import("./harness-e4avh192.js");
82
82
  setHarness(input.harness ?? "opencode");
83
83
  const [{ indexMessageInShortChunks }, { configureContextDatabasePragmas }] = await Promise.all([
84
- import("./message-index-bounded-w14496s9.js"),
84
+ import("./message-index-bounded-dgd8a2x1.js"),
85
85
  import("./sqlite-context-pragmas-mv9jqwjh.js")
86
86
  ]);
87
87
  configureContextDatabasePragmas(db);
@@ -7,7 +7,7 @@ import {
7
7
  setRecompTerminal2,
8
8
  buildRecompDeps2,
9
9
  runManagedRecomp2
10
- } from "./server-5by3vdzs.js";
10
+ } from "./server-405ap0b0.js";
11
11
  import"./server-r4430x9m.js";
12
12
  import"./server-nq3cb7be.js";
13
13
  import"./server-gkse1wyz.js";
@@ -16,7 +16,7 @@ import"./server-7acq7815.js";
16
16
  import"./server-4dhv7mqz.js";
17
17
  import"./server-t8y64xj7.js";
18
18
  import"./server-ypf1ap0v.js";
19
- import"./server-dfq5vb8j.js";
19
+ import"./server-dt9b00ja.js";
20
20
  import"./server-2amn2s73.js";
21
21
  import"./server-ef1mskas.js";
22
22
  import"./server-sd8hvzte.js";
@@ -5,7 +5,7 @@ import {
5
5
  } from "./server-qjyp27vf.js";
6
6
  import"./server-t8y64xj7.js";
7
7
  import"./server-ypf1ap0v.js";
8
- import"./server-dfq5vb8j.js";
8
+ import"./server-dt9b00ja.js";
9
9
  import"./server-2amn2s73.js";
10
10
  import"./server-ef1mskas.js";
11
11
  import"./server-jd7vzwn4.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  renderSearchArchive2,
3
3
  renderSearchArchiveOffThread2
4
- } from "./server-a9w5f0yw.js";
5
- import"./server-e51xmr4d.js";
4
+ } from "./server-2d01821b.js";
5
+ import"./server-2tp6y1qs.js";
6
6
  import"./server-kaqs6h31.js";
7
7
  import"./server-jd7vzwn4.js";
8
8
  import"./server-xfjjbrkt.js";
@@ -5,7 +5,7 @@ import {
5
5
  resolveMemoriesByIdsForSearch2,
6
6
  unifiedSearch2,
7
7
  formatSearchResults2
8
- } from "./server-7094pk3w.js";
8
+ } from "./server-r4mmc670.js";
9
9
  import"./server-kaqs6h31.js";
10
10
  import"./server-nq3cb7be.js";
11
11
  import"./server-gkse1wyz.js";
@@ -13,7 +13,7 @@ import"./server-jjvbk92s.js";
13
13
  import"./server-7acq7815.js";
14
14
  import"./server-4dhv7mqz.js";
15
15
  import"./server-ypf1ap0v.js";
16
- import"./server-dfq5vb8j.js";
16
+ import"./server-dt9b00ja.js";
17
17
  import"./server-2amn2s73.js";
18
18
  import"./server-qt1qqasc.js";
19
19
  import"./server-jd7vzwn4.js";
@@ -22,7 +22,7 @@ import {
22
22
  } from "./server-jd7vzwn4.js";
23
23
  import {
24
24
  readV2ArchiveOffThread2
25
- } from "./server-e51xmr4d.js";
25
+ } from "./server-2tp6y1qs.js";
26
26
 
27
27
  // src/tools/ctx-expand/search-archive.ts
28
28
  var archiveReadsOnThisThread = 0;
@@ -140,8 +140,8 @@ async function serveV2ArchiveReads2(port, openConnections) {
140
140
  import("./store-reader-cgx47zkp.js"),
141
141
  import("./store-z3qe67cg.js"),
142
142
  import("./read-session-chunk-tqnh1ret.js"),
143
- import("./render-5dz1knf2.js"),
144
- import("./search-archive-z6z9jqwf.js"),
143
+ import("./render-yyv8nv4p.js"),
144
+ import("./search-archive-gagdnrb3.js"),
145
145
  import("./expand-attachments-h33jbgyz.js")
146
146
  ]);
147
147
  const pool = new V2StoreReaderPool;
@@ -162,7 +162,7 @@ import {
162
162
  toMessageIndexSource,
163
163
  clearIndexedMessagesInTransaction,
164
164
  indexSourcesAfterOrdinal
165
- } from "./server-dfq5vb8j.js";
165
+ } from "./server-dt9b00ja.js";
166
166
  import {
167
167
  COMPARTMENT_LEASE_RENEWAL_MS,
168
168
  getCompartmentLeaseBlocker,
@@ -43,6 +43,39 @@ function keywordRelevance(query, content) {
43
43
  const words = new Set(terms(cleanSearchText(content)));
44
44
  return 0.8 * needles.filter((term) => words.has(term)).length / needles.length;
45
45
  }
46
+ var CJK_RUN = /^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]+$/u;
47
+ var CJK_RUN_SPLIT = /([\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]+)/u;
48
+ function hintTerms(text) {
49
+ return [
50
+ ...new Set(terms(text).flatMap((term) => term.split(CJK_RUN_SPLIT)).filter((term) => term.length > 0 && !QUERY_STOP_WORDS.has(term)))
51
+ ];
52
+ }
53
+ function characterBigrams(run) {
54
+ const characters = [...run];
55
+ return characters.length === 1 ? characters : characters.slice(1).map((character, index) => characters[index] + character);
56
+ }
57
+ function hintKeywordRelevance(query, content) {
58
+ const needles = hintTerms(query);
59
+ if (needles.length === 0)
60
+ return 0;
61
+ const words = new Set(hintTerms(cleanSearchText(content)));
62
+ const runs = [...words].filter((word) => CJK_RUN.test(word));
63
+ const bigrams = new Set(runs.flatMap(characterBigrams));
64
+ let matched = 0;
65
+ for (const needle of needles) {
66
+ if (!CJK_RUN.test(needle)) {
67
+ matched += Number(words.has(needle));
68
+ continue;
69
+ }
70
+ const grams = characterBigrams(needle);
71
+ if ([...needle].length === 1) {
72
+ matched += Number(runs.some((run) => run.includes(needle)));
73
+ continue;
74
+ }
75
+ matched += Math.min(1, grams.filter((gram) => bigrams.has(gram)).length / Math.ceil(grams.length / 2));
76
+ }
77
+ return 0.8 * matched / needles.length;
78
+ }
46
79
  function matchedSearchSnippet(content, query, cap = 220) {
47
80
  const text = cleanSearchText(content);
48
81
  const needles = new Set(terms(query));
@@ -535,4 +568,4 @@ function indexItemsAfterOrdinal(db, sessionId, items, finalWatermark, toSource)
535
568
  return inserted;
536
569
  }
537
570
 
538
- export { cleanSearchText, keywordRelevance, matchedSearchSnippet, clearCompressionDepth, clearCompressionDepthRange, MESSAGE_INDEX_MAX_FTS_BYTES, messageIndexSkipKey, toMessageIndexSource, getLastIndexedOrdinal, getIndexedMessageCorpusSize, markMessageIndexDirty, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, clearIndexedMessagesInTransaction, clearIndexedMessages, getIndexableContent, indexSingleMessage, indexMessagesAfterOrdinal, indexSourcesAfterOrdinal };
571
+ export { cleanSearchText, hintKeywordRelevance, matchedSearchSnippet, clearCompressionDepth, clearCompressionDepthRange, MESSAGE_INDEX_MAX_FTS_BYTES, messageIndexSkipKey, toMessageIndexSource, getLastIndexedOrdinal, getIndexedMessageCorpusSize, markMessageIndexDirty, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, clearIndexedMessagesInTransaction, clearIndexedMessages, getIndexableContent, indexSingleMessage, indexMessagesAfterOrdinal, indexSourcesAfterOrdinal };
@@ -18,14 +18,14 @@ import {
18
18
  } from "./server-xfjjbrkt.js";
19
19
  import {
20
20
  cleanSearchText,
21
- keywordRelevance,
21
+ hintKeywordRelevance,
22
22
  matchedSearchSnippet,
23
23
  getIndexedMessageCorpusSize,
24
24
  getMessageIndexReconciliationStartOrdinal,
25
25
  isMessageIndexReconciledThrough,
26
26
  clearIndexedMessages,
27
27
  indexMessagesAfterOrdinal
28
- } from "./server-dfq5vb8j.js";
28
+ } from "./server-dt9b00ja.js";
29
29
  import {
30
30
  Priority,
31
31
  AdmissionClass,
@@ -397,6 +397,11 @@ function invalidateIncrementalWork(sessionId) {
397
397
  }
398
398
 
399
399
  // src/features/magic-context/auto-search-diagnostics.ts
400
+ var memoryHintContent = new WeakMap;
401
+ function withMemoryHintContent(result, fullContent) {
402
+ memoryHintContent.set(result, fullContent);
403
+ return result;
404
+ }
400
405
  function createAutoSearchDiagnostics(threshold) {
401
406
  return {
402
407
  threshold,
@@ -408,9 +413,10 @@ function createAutoSearchDiagnostics(threshold) {
408
413
  };
409
414
  }
410
415
  function autoSearchRelevance(query, result) {
411
- if (cleanSearchText(result.source === "compartment" ? result.title : result.content).length === 0)
416
+ const content = result.source === "memory" ? memoryHintContent.get(result) ?? result.content : result.source === "compartment" ? result.title : result.content;
417
+ if (cleanSearchText(content).length === 0)
412
418
  return 0;
413
- return result.source === "message" || "matchType" in result && result.source !== "compartment" && result.matchType !== "semantic" ? keywordRelevance(query, result.content) : result.score;
419
+ return result.source === "message" || "matchType" in result && result.source !== "compartment" && result.matchType !== "semantic" ? hintKeywordRelevance(query, content) : result.score;
414
420
  }
415
421
  function recordAutoSearchLane(diagnostics, lane, query, results) {
416
422
  if (!diagnostics)
@@ -1944,19 +1950,15 @@ async function remoteScores(config, query, documents, signal) {
1944
1950
  "Content-Type": "application/json",
1945
1951
  ...config.api_key ? { Authorization: `Bearer ${config.api_key}` } : {}
1946
1952
  },
1947
- body: JSON.stringify(tei ? { query, texts: documents } : {
1948
- model: config.model,
1949
- query,
1950
- documents,
1951
- top_n: documents.length
1952
- }),
1953
+ body: JSON.stringify(tei ? { query, texts: documents } : { model: config.model, query, documents }),
1953
1954
  signal: controller.signal,
1954
1955
  redirect: "error"
1955
1956
  });
1956
1957
  if (!response.ok)
1957
1958
  throw new RerankFailure(`http_${response.status}`);
1958
1959
  const body = await response.json();
1959
- const rows = tei ? body : body?.results;
1960
+ const reply = body;
1961
+ const rows = tei ? body : reply?.results ?? reply?.data;
1960
1962
  if (!Array.isArray(rows) || rows.length !== documents.length)
1961
1963
  throw new RerankFailure("invalid_reply");
1962
1964
  const scores = new Array(documents.length);
@@ -2558,7 +2560,7 @@ function mergeMemoryResults(args) {
2558
2560
  suppressedVisibleIds.push(id);
2559
2561
  continue;
2560
2562
  }
2561
- results.push({
2563
+ results.push(withMemoryHintContent({
2562
2564
  source: "memory",
2563
2565
  content: previewText(memory.content),
2564
2566
  score,
@@ -2566,7 +2568,7 @@ function mergeMemoryResults(args) {
2566
2568
  category: memory.category,
2567
2569
  matchType,
2568
2570
  sourceName: args.sourceNameByMemoryId?.get(memory.id)
2569
- });
2571
+ }, memory.content));
2570
2572
  }
2571
2573
  return {
2572
2574
  results: results.sort((left, right) => {
package/dist/v2/server.js CHANGED
@@ -7875,7 +7875,7 @@ var require_src2 = __commonJS(function(exports, module) {
7875
7875
  // package.json
7876
7876
  var package_default = {
7877
7877
  name: "@cortexkit/opencode-magic-context",
7878
- version: "0.49.37",
7878
+ version: "0.49.39",
7879
7879
  type: "module",
7880
7880
  description: "OpenCode plugin for Magic Context — cross-session memory and context management",
7881
7881
  main: "dist/index.js",
@@ -8196,7 +8196,7 @@ async function setup(context) {
8196
8196
  if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
8197
8197
  log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
8198
8198
  }
8199
- const { registerContext } = await import("./context-05x7kr7f.js");
8199
+ const { registerContext } = await import("./context-ejyvb9kp.js");
8200
8200
  setHarness2("opencode2");
8201
8201
  bindStaleBuildNotice({}, import.meta.url, "opencode2");
8202
8202
  const duties = await registerContext(context);
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  readV2ArchiveOffThread2,
3
3
  serveV2ArchiveReads2
4
- } from "./server-e51xmr4d.js";
4
+ } from "./server-2tp6y1qs.js";
5
5
  import"./server-v0p37hm2.js";
6
6
  import"./server-gzy5w8ya.js";
7
7
  import"./server-1d042x6w.js";
@@ -24,7 +24,7 @@ import"./server-1d042x6w.js";
24
24
  import"./server-tnzbk64q.js";
25
25
  import"./server-nmyganc8.js";
26
26
  import"./server-cp1a03vc.js";
27
- import"./server-dfq5vb8j.js";
27
+ import"./server-dt9b00ja.js";
28
28
  import {
29
29
  getWrapupInProgressState,
30
30
  acquireWrapupInProgress,
@@ -63,7 +63,7 @@ import {
63
63
  registerActiveCompartmentRun,
64
64
  setRecompStarting2,
65
65
  setRecompTerminal2
66
- } from "./server-5by3vdzs.js";
66
+ } from "./server-405ap0b0.js";
67
67
  import"./server-qt1qqasc.js";
68
68
  import"./server-7acq7815.js";
69
69
  import"./server-dcws5831.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  readV2ArchiveOffThread2,
3
3
  serveV2ArchiveReads2
4
- } from "./index-prw8apnc.js";
4
+ } from "./index-z7etaphs.js";
5
5
  import"./index-v0p37hm2.js";
6
6
  import"./index-gzy5w8ya.js";
7
7
  import"./index-1d042x6w.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  runManagedWrapup2
3
- } from "./index-pp8vdn01.js";
4
- import"./index-ys7j6679.js";
5
- import"./index-9tdvbdv1.js";
3
+ } from "./index-wk7x13qv.js";
4
+ import"./index-m8v7nqgp.js";
5
+ import"./index-tr6vcwt0.js";
6
6
  import"./index-850vthn3.js";
7
7
  import"./index-sd3egckz.js";
8
8
  import"./index-xnm0wq1r.js";
@@ -12,7 +12,7 @@ import"./index-21fgrfrf.js";
12
12
  import"./index-4dhv7mqz.js";
13
13
  import"./index-72czy45z.js";
14
14
  import"./index-2qbtqg1w.js";
15
- import"./index-2rs7912w.js";
15
+ import"./index-9z4d2ha0.js";
16
16
  import"./index-2amn2s73.js";
17
17
  import"./index-66a50f3e.js";
18
18
  import"./index-dnqqqc5f.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-magic-context",
3
- "version": "0.49.37",
3
+ "version": "0.49.39",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",
@@ -1,7 +1,42 @@
1
1
  import { expect, test } from "bun:test";
2
- import { cleanSearchText, keywordRelevance, matchedSearchSnippet } from "./search-text";
2
+ import {
3
+ cleanSearchText,
4
+ hintKeywordRelevance,
5
+ keywordRelevance,
6
+ matchedSearchSnippet,
7
+ } from "./search-text";
3
8
  import { removeSystemReminders } from "./system-directive";
4
9
 
10
+ test("hint scoring preserves exact English and other space-separated keyword scores", () => {
11
+ const cases: Array<[string, string, number]> = [
12
+ ["explain historian cache wiring", "cache icons", 0.2],
13
+ ["historian cache wiring", "historian cache wiring details", 0.8000000000000002],
14
+ ["please explain cache wiring to me", "cache wiring", 0.5333333333333333],
15
+ ["CACHE cache cache_timeout", "cache_timeout", 0.4],
16
+ ["how are you", "how are you", 0],
17
+ ["historian cache", "<task>historian cache</task>", 0],
18
+ ["résumé über prüfen", "über prüfen", 0.5333333333333333],
19
+ ["память кеш", "кеш", 0.4],
20
+ ["ذاكرة تخزين", "تخزين", 0.4],
21
+ ];
22
+ for (const [query, content, expected] of cases) {
23
+ expect(keywordRelevance(query, content)).toBe(expected);
24
+ expect(hintKeywordRelevance(query, content)).toBe(expected);
25
+ }
26
+ });
27
+
28
+ test("only hint scoring splits unspaced CJK runs into overlapping character bigrams", () => {
29
+ expect(keywordRelevance("MC_Maze 残差怎样汇总?", "MC_Maze 残差按种子汇总。")).toBe(0.4);
30
+ expect(hintKeywordRelevance("残差", "残留")).toBe(0);
31
+ expect(hintKeywordRelevance("差", "残差")).toBe(0.8);
32
+ expect(hintKeywordRelevance("𠮷野家", "𠮷野川")).toBe(0.8);
33
+ expect(hintKeywordRelevance("かながき", "かながきです")).toBe(0.8);
34
+ expect(hintKeywordRelevance("カタカナ", "カタカナです")).toBe(0.8);
35
+ expect(hintKeywordRelevance("프로젝트캐시", "프로젝트의캐시")).toBe(0.8);
36
+ expect(hintKeywordRelevance("cache残差", "cache残差按种子汇总")).toBe(0.8);
37
+ expect(hintKeywordRelevance("差", "<task>残差</task> unrelated")).toBe(0);
38
+ });
39
+
5
40
  test("nested reminder contents stay quarantined through the outer closing tag", () => {
6
41
  expect(
7
42
  removeSystemReminders(
@@ -35,6 +35,54 @@ export function keywordRelevance(query: string, content: string): number {
35
35
  return (0.8 * needles.filter((term) => words.has(term)).length) / needles.length;
36
36
  }
37
37
 
38
+ const CJK_RUN = /^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]+$/u;
39
+ const CJK_RUN_SPLIT = /([\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]+)/u;
40
+
41
+ function hintTerms(text: string): string[] {
42
+ return [
43
+ ...new Set(
44
+ terms(text)
45
+ .flatMap((term) => term.split(CJK_RUN_SPLIT))
46
+ .filter((term) => term.length > 0 && !QUERY_STOP_WORDS.has(term)),
47
+ ),
48
+ ];
49
+ }
50
+
51
+ function characterBigrams(run: string): string[] {
52
+ const characters = [...run];
53
+ return characters.length === 1
54
+ ? characters
55
+ : characters.slice(1).map((character, index) => characters[index] + character);
56
+ }
57
+
58
+ /** Match unspaced clauses for hints without changing retrieval or snippet scoring. */
59
+ export function hintKeywordRelevance(query: string, content: string): number {
60
+ const needles = hintTerms(query);
61
+ if (needles.length === 0) return 0;
62
+ const words = new Set(hintTerms(cleanSearchText(content)));
63
+ const runs = [...words].filter((word) => CJK_RUN.test(word));
64
+ const bigrams = new Set(runs.flatMap(characterBigrams));
65
+ let matched = 0;
66
+ for (const needle of needles) {
67
+ if (!CJK_RUN.test(needle)) {
68
+ matched += Number(words.has(needle));
69
+ continue;
70
+ }
71
+ const grams = characterBigrams(needle);
72
+ if ([...needle].length === 1) {
73
+ matched += Number(runs.some((run) => run.includes(needle)));
74
+ continue;
75
+ }
76
+ // Count each clause as one term so filler bigrams across word boundaries
77
+ // do not dilute it; require half coverage so shared function words alone do not pass.
78
+ matched += Math.min(
79
+ 1,
80
+ grams.filter((gram) => bigrams.has(gram)).length / Math.ceil(grams.length / 2),
81
+ );
82
+ }
83
+ return (0.8 * matched) / needles.length;
84
+ }
85
+
38
86
  /** Pick the densest matching passage before compression can discard the matched words. */
39
87
  export function matchedSearchSnippet(content: string, query: string, cap = 220): string {
40
88
  const text = cleanSearchText(content);