@cortexkit/pi-magic-context 0.49.80 → 0.49.82

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 (30) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +4 -4
  3. package/dist/{embedding-backfill-arvg2p6f.js → embedding-backfill-yh10bmx5.js} +4 -4
  4. package/dist/{index-0bmsfzqf.js → index-3g1wy4z9.js} +2 -2
  5. package/dist/{index-pz85rpzf.js → index-47g3pgzk.js} +10 -5
  6. package/dist/{index-q1yc6bs0.js → index-7thk2cwt.js} +15 -4
  7. package/dist/{index-gavj3e6h.js → index-e0zdn1p3.js} +1 -1
  8. package/dist/{index-79xfn84y.js → index-gdy08gn6.js} +1 -1
  9. package/dist/{index-453s1hj6.js → index-hna2sxy8.js} +1 -1
  10. package/dist/{index-5tkveh4p.js → index-k8xz22jc.js} +1 -1
  11. package/dist/{index-k7a8x7ba.js → index-nmmge3j6.js} +1 -1
  12. package/dist/{index-nvh6d3bz.js → index-qky62xze.js} +34 -2
  13. package/dist/{index-6crdakkm.js → index-qz43gkqe.js} +31 -12
  14. package/dist/{index-hnvq96j6.js → index-wtqv3vha.js} +4 -4
  15. package/dist/{index-0th11rhf.js → index-xz5b9t4g.js} +2 -2
  16. package/dist/{index-5009ew3c.js → index-y573dt51.js} +21 -20
  17. package/dist/index.js +101 -21
  18. package/dist/migration-worker.js +3 -3
  19. package/dist/{project-embedding-registry-zgzq9ehw.js → project-embedding-registry-3sss39rx.js} +3 -3
  20. package/dist/raw-ordinal-warmup-worker.js +2 -2
  21. package/dist/{render-fhrce5g6.js → render-9xgp0jka.js} +6 -6
  22. package/dist/{rpc-notifications-gm1mdpwh.js → rpc-notifications-889zvhn2.js} +3 -1
  23. package/dist/{search-archive-661vc3fb.js → search-archive-wr38qtkw.js} +1 -1
  24. package/dist/{search-vw6ps2me.js → search-dh4ryftv.js} +7 -7
  25. package/dist/{store-reader-mmfw2h48.js → store-reader-8j41p18c.js} +1 -1
  26. package/dist/{store-e9ve3qzt.js → store-xg9ez6jn.js} +1 -1
  27. package/dist/subagent-entry.js +12 -12
  28. package/dist/tag-snapshot-worker-pi.js +3 -3
  29. package/dist/{v2-archive-reader-zndhp4c4.js → v2-archive-reader-8m9mw6sv.js} +1 -1
  30. package/package.json +1 -1
@@ -27,11 +27,11 @@ serveWorkerJobs(async (initial, port) => {
27
27
  { Database, registerSqliteDiagnosticSink },
28
28
  { log }
29
29
  ] = await Promise.all([
30
- import("./embedding-backfill-arvg2p6f.js"),
30
+ import("./embedding-backfill-yh10bmx5.js"),
31
31
  import("./embedding-cache-7rp4gqzr.js"),
32
32
  import("./storage-memory-0ndn65fm.js"),
33
- import("./project-embedding-registry-zgzq9ehw.js"),
34
- import("./search-vw6ps2me.js"),
33
+ import("./project-embedding-registry-3sss39rx.js"),
34
+ import("./search-dh4ryftv.js"),
35
35
  import("./compartment-chunk-embedding-avkyp2df.js"),
36
36
  import("./embedding-activity-ew6dshfd.js"),
37
37
  import("./harness-9872e0ym.js"),
@@ -30,14 +30,14 @@ import {
30
30
  acquireGitSweepLease,
31
31
  renewGitSweepLease,
32
32
  releaseGitSweepLease
33
- } from "./index-79xfn84y.js";
34
- import"./index-453s1hj6.js";
33
+ } from "./index-gdy08gn6.js";
34
+ import"./index-hna2sxy8.js";
35
35
  import {
36
36
  LATEST_SUPPORTED_VERSION,
37
37
  enforceSchemaFence
38
- } from "./index-0th11rhf.js";
38
+ } from "./index-xz5b9t4g.js";
39
39
  import"./index-3bb24eb6.js";
40
- import"./index-gavj3e6h.js";
40
+ import"./index-e0zdn1p3.js";
41
41
  import"./index-jhmz9tgv.js";
42
42
  import"./index-135e8hvg.js";
43
43
  import"./index-n0zjvs3h.js";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  ensureMemoryEmbeddings2
3
- } from "./index-5tkveh4p.js";
4
- import"./index-0bmsfzqf.js";
3
+ } from "./index-k8xz22jc.js";
4
+ import"./index-3g1wy4z9.js";
5
5
  import"./index-9p40dgkm.js";
6
6
  import"./index-hgd00nas.js";
7
7
  import"./index-yhzhdp3m.js";
8
- import"./index-79xfn84y.js";
8
+ import"./index-gdy08gn6.js";
9
9
  import"./index-cxczethe.js";
10
10
  import"./index-txcs0vnj.js";
11
11
  import"./index-5rcjs14a.js";
12
12
  import"./index-vcegxfwg.js";
13
- import"./index-453s1hj6.js";
13
+ import"./index-hna2sxy8.js";
14
14
  import"./index-ghp32f9m.js";
15
15
  import"./index-xjhq27z9.js";
16
16
  import"./index-wfqysrwq.js";
@@ -67,7 +67,7 @@ import {
67
67
  } from "./index-hgd00nas.js";
68
68
  import {
69
69
  setBootQuietPeriodForTests
70
- } from "./index-453s1hj6.js";
70
+ } from "./index-hna2sxy8.js";
71
71
  import {
72
72
  isEmbeddingHostBusy2
73
73
  } from "./index-9p40dgkm.js";
@@ -78,7 +78,7 @@ import {
78
78
  acquireGitSweepLease,
79
79
  renewGitSweepLease,
80
80
  releaseGitSweepLease
81
- } from "./index-79xfn84y.js";
81
+ } from "./index-gdy08gn6.js";
82
82
  import {
83
83
  saveEmbeddingIfHashMatches,
84
84
  getMemoryEmbedCoverage,
@@ -56,20 +56,20 @@ import {
56
56
  getProjectEmbeddingSnapshot2,
57
57
  embedTextForProject2,
58
58
  embedItemsForProject2
59
- } from "./index-0bmsfzqf.js";
59
+ } from "./index-3g1wy4z9.js";
60
60
  import {
61
61
  recordEmbeddingMeasurement
62
62
  } from "./index-hgd00nas.js";
63
63
  import {
64
64
  scheduleAfterBootQuiet
65
- } from "./index-453s1hj6.js";
65
+ } from "./index-hna2sxy8.js";
66
66
  import {
67
67
  saveEmbeddingIfHashMatches,
68
68
  getProjectEmbeddings2
69
69
  } from "./index-yhzhdp3m.js";
70
70
  import {
71
71
  ensureMemoryEmbeddings2
72
- } from "./index-5tkveh4p.js";
72
+ } from "./index-k8xz22jc.js";
73
73
  import {
74
74
  getMemorySelectColumns2,
75
75
  isMemoryRow2,
@@ -108,11 +108,11 @@ import {
108
108
  expandWorkspaceIdentitySetWithAliases,
109
109
  resolveStoredPathWorkspaceIdentity,
110
110
  sourceNameForMemory
111
- } from "./index-gavj3e6h.js";
111
+ } from "./index-e0zdn1p3.js";
112
112
  import {
113
113
  getNotes,
114
114
  getActivePrimers
115
- } from "./index-k7a8x7ba.js";
115
+ } from "./index-nmmge3j6.js";
116
116
  import {
117
117
  computeNormalizedHash
118
118
  } from "./index-9x1f96r8.js";
@@ -132,6 +132,11 @@ var USER_FACING_FAILURES = {
132
132
  sentence: "History compression is paused because this session's saved summaries no longer line up with its messages.",
133
133
  action: "Run /ctx-recomp to rebuild them."
134
134
  },
135
+ fork_history_gap: {
136
+ code: "MC-H09",
137
+ sentence: "This fork's saved history has a gap.",
138
+ action: "Run /ctx-recomp to rebuild its history."
139
+ },
135
140
  history_boundary_unresolved: {
136
141
  code: "MC-H04",
137
142
  sentence: "This request was not sent: it is larger than the model's context window, and Magic Context could not cut the already-summarized history out of it.",
@@ -15,9 +15,20 @@ function notificationMatchesSink(notification, sink) {
15
15
  return notification.sessionId === sink.sessionId;
16
16
  return sink.protocol !== 2;
17
17
  }
18
- function pushNotification2(type, payload, sessionId) {
18
+ function pushLiveNotification2(type, payload, sessionId) {
19
19
  const notification = { id: nextNotificationId++, type, payload, sessionId };
20
- queue.push(notification);
20
+ for (const sink of sinks) {
21
+ if (sink.sessionId !== sessionId)
22
+ continue;
23
+ try {
24
+ sink.send(notification);
25
+ } catch {}
26
+ }
27
+ }
28
+ function pushNotification2(type, payload, sessionId, options) {
29
+ const notification = { id: nextNotificationId++, type, payload, sessionId };
30
+ if (!options?.liveOnly)
31
+ queue.push(notification);
21
32
  for (const sink of sinks) {
22
33
  if (!notificationMatchesSink(notification, sink))
23
34
  continue;
@@ -25,7 +36,7 @@ function pushNotification2(type, payload, sessionId) {
25
36
  sink.send(notification);
26
37
  } catch {}
27
38
  }
28
- if (queue.length > 100) {
39
+ if (!options?.liveOnly && queue.length > 100) {
29
40
  const reservedIds = new Set;
30
41
  const reservedScopes = new Set;
31
42
  for (let i = queue.length - 1;i >= 0 && reservedScopes.size < 25; i -= 1) {
@@ -101,4 +112,4 @@ function isTuiConnected2(sessionId) {
101
112
  return false;
102
113
  }
103
114
 
104
- export { registerNotificationSink2, pushNotification2, acknowledgeNotifications2, __resetNotificationStateForTests2, drainNotifications2, isTuiConnected2 };
115
+ export { registerNotificationSink2, pushLiveNotification2, pushNotification2, acknowledgeNotifications2, __resetNotificationStateForTests2, drainNotifications2, isTuiConnected2 };
@@ -20,7 +20,7 @@ import {
20
20
  import {
21
21
  normalizeStoredProjectPath,
22
22
  storedPathBelongsToIdentity
23
- } from "./index-453s1hj6.js";
23
+ } from "./index-hna2sxy8.js";
24
24
  import {
25
25
  logSlowWriteTransaction
26
26
  } from "./index-1ts77n1b.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-0h2mkab2.js";
4
4
  import {
5
5
  isUserHomeDirectory
6
- } from "./index-453s1hj6.js";
6
+ } from "./index-hna2sxy8.js";
7
7
  import {
8
8
  logSlowWriteTransaction
9
9
  } from "./index-1ts77n1b.js";
@@ -696,4 +696,4 @@ function setBootQuietPeriodForTests(startAtMs) {
696
696
  bootQuietUntilMs = startAtMs === null ? 0 : startAtMs + BOOT_QUIET_MS;
697
697
  }
698
698
 
699
- export { pruneMissingProjectIdentities, setHomeProjectPermission, ProjectIdentityError, resolveProjectIdentityStrict, isUserHomeDirectory, resolveProjectIdentity, directoryHasGitMetadata, isUsableProjectIdentity, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, beginBootQuietPeriod, scheduleAfterBootQuiet, setBootQuietPeriodForTests };
699
+ export { pruneMissingProjectIdentities, setHomeProjectPermission, ProjectIdentityError, directoryFallback, resolveProjectIdentityStrict, isUserHomeDirectory, resolveProjectIdentity, directoryHasGitMetadata, isUsableProjectIdentity, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, beginBootQuietPeriod, scheduleAfterBootQuiet, setBootQuietPeriodForTests };
@@ -10,7 +10,7 @@ import {
10
10
  readSearchBackfillCursor2,
11
11
  writeSearchBackfillCursor2,
12
12
  embedItemsWindowBounded2
13
- } from "./index-0bmsfzqf.js";
13
+ } from "./index-3g1wy4z9.js";
14
14
  import {
15
15
  saveEmbeddingIfHashMatches
16
16
  } from "./index-yhzhdp3m.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./index-2qtx0q6h.js";
7
7
  import {
8
8
  managedAuthorityNoteRow
9
- } from "./index-gavj3e6h.js";
9
+ } from "./index-e0zdn1p3.js";
10
10
 
11
11
  // ../plugin/src/features/magic-context/storage-notes.ts
12
12
  var NOTE_TYPES = new Set(["session", "smart"]);
@@ -439,7 +439,7 @@ class V2StoreReader2 {
439
439
  const order = columns.has("time_updated") ? "time_updated DESC, id DESC" : "id DESC";
440
440
  const page = this.prepare(`SELECT id, COALESCE(directory, '') AS directory FROM session_v2
441
441
  WHERE parent_id IS NULL${archived}
442
- AND COALESCE(json_extract(metadata, '$.magic_context'), '') <> 'hidden-run'
442
+ AND COALESCE(json_extract(metadata, '$.magic_context'), '') NOT IN ('hidden-run', 'background-holder')
443
443
  ORDER BY ${order} LIMIT ? OFFSET ?`);
444
444
  const pageSize = 500;
445
445
  for (let offset = 0;; offset += pageSize) {
@@ -460,7 +460,7 @@ class V2StoreReader2 {
460
460
  WHERE session_id = session_v2.id AND type = 'user'
461
461
  ) AS time FROM session_v2
462
462
  WHERE parent_id IS NULL
463
- AND COALESCE(json_extract(metadata, '$.magic_context'), '') <> 'hidden-run'
463
+ AND COALESCE(json_extract(metadata, '$.magic_context'), '') NOT IN ('hidden-run', 'background-holder')
464
464
  AND id IN (${chunk.map(() => "?").join(",")})`).all(...chunk);
465
465
  for (const row of rows)
466
466
  if (row.time !== null)
@@ -746,6 +746,38 @@ class V2StoreReader2 {
746
746
  return this.prepare(`SELECT id, type, seq, time_created FROM session_message
747
747
  WHERE session_id = ? AND seq <= ? ORDER BY seq ASC`).all(sessionID, throughSeq);
748
748
  }
749
+ matchingForkBodies(parentID, forkID, throughSeq) {
750
+ const matchParts = this.hasPartTable() ? `
751
+ AND NOT EXISTS (
752
+ SELECT ordinal, type, call_id, data FROM session_part WHERE message_id = p.id
753
+ EXCEPT SELECT ordinal, type, call_id, data FROM session_part WHERE message_id = f.id
754
+ ) AND NOT EXISTS (
755
+ SELECT ordinal, type, call_id, data FROM session_part WHERE message_id = f.id
756
+ EXCEPT SELECT ordinal, type, call_id, data FROM session_part WHERE message_id = p.id
757
+ )` : "";
758
+ const rows = this.prepare(`SELECT p.id AS parentId, f.id AS forkId FROM session_message p JOIN session_message f ON f.seq = p.seq
759
+ WHERE p.session_id = ? AND f.session_id = ? AND p.seq <= ?
760
+ AND p.type = f.type AND p.time_created = f.time_created AND p.data = f.data${matchParts}`).all(parentID, forkID, throughSeq);
761
+ return new Map(rows.map(({ parentId, forkId }) => [parentId, forkId]));
762
+ }
763
+ *iterateRawMessageRange(sessionID, from, to) {
764
+ if (!Number.isSafeInteger(from) || !Number.isSafeInteger(to) || from < 1 || to < from)
765
+ return;
766
+ let anchor;
767
+ for (let after = from - 1;after < to; after += 1) {
768
+ const [row] = this.messagePage(sessionID, after, 1, to, anchor);
769
+ if (!row)
770
+ return;
771
+ anchor = { id: row.id, timeCreated: row.time_created ?? 0 };
772
+ yield row;
773
+ }
774
+ }
775
+ messageCountAndNewestId(sessionID) {
776
+ const row = this.prepare(`SELECT COUNT(*) AS count, (
777
+ SELECT id FROM session_message WHERE session_id = ? ORDER BY seq DESC LIMIT 1
778
+ ) AS newestId FROM session_message WHERE session_id = ?`).get(sessionID, sessionID);
779
+ return [row.count, row.newestId];
780
+ }
749
781
  latestSequenceForIds(sessionID, ids) {
750
782
  let latest = -1;
751
783
  for (let offset = 0;offset < ids.length; offset += 500) {
@@ -61,7 +61,7 @@ import {
61
61
  import {
62
62
  isPidAlive,
63
63
  readProcessStartTime
64
- } from "./index-0th11rhf.js";
64
+ } from "./index-xz5b9t4g.js";
65
65
  import {
66
66
  withReadOnlySessionDb,
67
67
  expandToolPart,
@@ -71,7 +71,7 @@ import {
71
71
  import {
72
72
  gaDatabasePath2,
73
73
  V2StoreReader2
74
- } from "./index-nvh6d3bz.js";
74
+ } from "./index-qky62xze.js";
75
75
  import {
76
76
  deleteUnmappedMessageFtsRows2
77
77
  } from "./index-ghp32f9m.js";
@@ -85,7 +85,7 @@ import {
85
85
  import {
86
86
  layoutLkgPrefix,
87
87
  assembleLkgPrefix
88
- } from "./index-gavj3e6h.js";
88
+ } from "./index-e0zdn1p3.js";
89
89
  import {
90
90
  logSlowWriteTransaction
91
91
  } from "./index-1ts77n1b.js";
@@ -3951,9 +3951,10 @@ function copySessionStateForClone(db, sourceSessionId, destinationSessionId, fil
3951
3951
  const compartmentColumns = db.prepare("PRAGMA table_info(compartments)").all();
3952
3952
  const hasBlockIndices = ["start_block_index", "end_block_index"].every((name) => compartmentColumns.some((column) => column.name === name));
3953
3953
  const blockProjection = hasBlockIndices ? "start_block_index, end_block_index" : "NULL AS start_block_index, NULL AS end_block_index";
3954
+ const rebaseProjection = compartmentColumns.some(({ name }) => name === "rebase_status") ? "rebase_status" : "NULL AS rebase_status";
3954
3955
  const sourceCompartments = db.prepare(`SELECT sequence, start_message, end_message, start_message_id, end_message_id,
3955
3956
  title, content, p1, p2, p3, p4, importance, episode_type, legacy,
3956
- created_at, harness, ${blockProjection}
3957
+ created_at, harness, ${blockProjection}, ${rebaseProjection}
3957
3958
  FROM compartments WHERE session_id = ? ORDER BY sequence ASC`).all(sourceSessionId);
3958
3959
  const insertCompartment = db.prepare(`INSERT INTO compartments
3959
3960
  (session_id, sequence, start_message, end_message, start_message_id,
@@ -3961,18 +3962,31 @@ function copySessionStateForClone(db, sourceSessionId, destinationSessionId, fil
3961
3962
  episode_type, legacy, created_at, harness${hasBlockIndices ? ", start_block_index, end_block_index" : ""})
3962
3963
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?${hasBlockIndices ? ", ?, ?" : ""})`);
3963
3964
  const copiedCompartments = [];
3965
+ const selected = filter.selectCompartments?.(sourceCompartments.map((row) => ({
3966
+ sequence: row.sequence,
3967
+ startMessage: row.start_message,
3968
+ endMessage: row.end_message,
3969
+ startMessageId: row.start_message_id,
3970
+ endMessageId: row.end_message_id,
3971
+ rebaseStatus: row.rebase_status
3972
+ })));
3964
3973
  for (const row of sourceCompartments) {
3965
- const startMessage = filter.resolveBoundaryOrdinal(row.start_message_id);
3966
- const endMessage = filter.resolveBoundaryOrdinal(row.end_message_id);
3974
+ const mapped = selected?.get(row.sequence);
3975
+ if (selected && !mapped)
3976
+ continue;
3977
+ const startMessage = mapped?.startMessage ?? filter.resolveBoundaryOrdinal(row.start_message_id);
3978
+ const endMessage = mapped?.endMessage ?? filter.resolveBoundaryOrdinal(row.end_message_id);
3967
3979
  if (startMessage === undefined || endMessage === undefined)
3968
3980
  continue;
3969
- insertCompartment.run(destinationSessionId, row.sequence, startMessage, endMessage, mapMessageId(filter, row.start_message_id), mapMessageId(filter, row.end_message_id), row.title, row.content, row.p1, row.p2, row.p3, row.p4, row.importance, row.episode_type, row.legacy, row.created_at, row.harness, ...hasBlockIndices ? [row.start_block_index, row.end_block_index] : []);
3981
+ const startMessageId = mapped?.startMessageId ?? mapMessageId(filter, row.start_message_id);
3982
+ const endMessageId = mapped?.endMessageId ?? mapMessageId(filter, row.end_message_id);
3983
+ insertCompartment.run(destinationSessionId, row.sequence, startMessage, endMessage, startMessageId, endMessageId, row.title, row.content, row.p1, row.p2, row.p3, row.p4, row.importance, row.episode_type, row.legacy, row.created_at, row.harness, ...hasBlockIndices ? [row.start_block_index, row.end_block_index] : []);
3970
3984
  copiedCompartments.push({
3971
3985
  sequence: row.sequence,
3972
3986
  startMessage,
3973
3987
  endMessage,
3974
- startMessageId: mapMessageId(filter, row.start_message_id) ?? row.start_message_id,
3975
- endMessageId: mapMessageId(filter, row.end_message_id) ?? row.end_message_id
3988
+ startMessageId: startMessageId ?? row.start_message_id,
3989
+ endMessageId: endMessageId ?? row.end_message_id
3976
3990
  });
3977
3991
  }
3978
3992
  const sourceTags = db.prepare(`SELECT id, message_id, type, status, byte_size, tag_number, harness,
@@ -4050,7 +4064,8 @@ function copySessionStateForClone(db, sourceSessionId, destinationSessionId, fil
4050
4064
  if (pendingMarker === null)
4051
4065
  clearedMarker = getPendingPiCompactionMarkerState(db, destinationSessionId);
4052
4066
  const todoAnchor = meta?.todo_synthetic_anchor_message_id ?? "";
4053
- const migrateTodo = todoAnchor.length > 0 && filter.includeMessageId(todoAnchor);
4067
+ const replayFilter = filter.includeReplayMessageId ? { ...filter, includeMessageId: filter.includeReplayMessageId } : filter;
4068
+ const migrateTodo = todoAnchor.length > 0 && replayFilter.includeMessageId(todoAnchor);
4054
4069
  db.prepare(`INSERT INTO session_meta
4055
4070
  (session_id, harness, counter, cleared_reasoning_through_tag,
4056
4071
  tool_reclaim_watermark, pi_stable_id_scheme, stripped_placeholder_ids,
@@ -4075,11 +4090,15 @@ function copySessionStateForClone(db, sourceSessionId, destinationSessionId, fil
4075
4090
  todo_synthetic_anchor_message_id = excluded.todo_synthetic_anchor_message_id,
4076
4091
  todo_synthetic_state_json = excluded.todo_synthetic_state_json,
4077
4092
  cached_m0_bytes = NULL,
4078
- cached_m1_bytes = NULL`).run(destinationSessionId, getHarness2(), maxCopiedTag, clampWatermark(meta?.cleared_reasoning_through_tag ?? null, maxCopiedTag), clampWatermark(meta?.tool_reclaim_watermark ?? null, maxCopiedTag), typeof meta?.pi_stable_id_scheme === "number" && Number.isFinite(meta.pi_stable_id_scheme) ? meta.pi_stable_id_scheme : null, filterStrippedPlaceholderBlob(meta?.stripped_placeholder_ids ?? null, filter), filterIdBlob(meta?.stale_reduce_stripped_ids ?? null, filter), filterProcessedImageBlob(meta?.processed_image_stripped_ids ?? null, filter), clonePiContentDecisions(meta?.merged_reasoning_stripped_ids ?? null, filter), pendingMarker, migrateTodo ? meta?.last_todo_state ?? "" : "", migrateTodo ? meta?.todo_synthetic_call_id ?? "" : "", migrateTodo ? mapMessageId(filter, todoAnchor) ?? "" : "", migrateTodo ? meta?.todo_synthetic_state_json ?? "" : "");
4093
+ cached_m1_bytes = NULL`).run(destinationSessionId, getHarness2(), maxCopiedTag, clampWatermark(meta?.cleared_reasoning_through_tag ?? null, maxCopiedTag), clampWatermark(meta?.tool_reclaim_watermark ?? null, maxCopiedTag), typeof meta?.pi_stable_id_scheme === "number" && Number.isFinite(meta.pi_stable_id_scheme) ? meta.pi_stable_id_scheme : null, filterStrippedPlaceholderBlob(meta?.stripped_placeholder_ids ?? null, replayFilter), filterIdBlob(meta?.stale_reduce_stripped_ids ?? null, replayFilter), filterProcessedImageBlob(meta?.processed_image_stripped_ids ?? null, replayFilter), clonePiContentDecisions(meta?.merged_reasoning_stripped_ids ?? null, replayFilter), pendingMarker, migrateTodo ? meta?.last_todo_state ?? "" : "", migrateTodo ? meta?.todo_synthetic_call_id ?? "" : "", migrateTodo ? mapMessageId(filter, todoAnchor) ?? "" : "", migrateTodo ? meta?.todo_synthetic_state_json ?? "" : "");
4094
+ const inheritedGaps = filter.inheritedCoordinateGaps?.() ?? [];
4095
+ if (inheritedGaps.length > 0) {
4096
+ db.prepare("UPDATE session_meta SET coordinate_rebase_notice = ? WHERE session_id = ?").run(JSON.stringify({ generation: "v2", inheritedGaps }), destinationSessionId);
4097
+ }
4079
4098
  const metaColumnRows = db.prepare("PRAGMA table_info(session_meta)").all();
4080
4099
  const metaColumns = new Set(metaColumnRows.map((column) => column.name));
4081
4100
  if (metaColumns.has("trailing_blank_decisions")) {
4082
- const replayDocument = cloneReplayDocument(db, sourceSessionId, copiedToolCallIds, filter);
4101
+ const replayDocument = cloneReplayDocument(db, sourceSessionId, copiedToolCallIds, replayFilter);
4083
4102
  writeReplayDocument(db, destinationSessionId, replayDocument);
4084
4103
  }
4085
4104
  const pendingOpsRow = db.prepare("SELECT COUNT(*) AS count FROM pending_ops WHERE session_id = ?").get(destinationSessionId);
@@ -137,11 +137,11 @@ async function serveV2ArchiveReads2(port, openConnections) {
137
137
  { createV2RecoveryAttachments }
138
138
  ] = await Promise.all([
139
139
  import("./sqlite-v89bj0yy.js"),
140
- import("./store-reader-mmfw2h48.js"),
141
- import("./store-e9ve3qzt.js"),
140
+ import("./store-reader-8j41p18c.js"),
141
+ import("./store-xg9ez6jn.js"),
142
142
  import("./read-session-chunk-wek7gb7j.js"),
143
- import("./render-fhrce5g6.js"),
144
- import("./search-archive-661vc3fb.js"),
143
+ import("./render-9xgp0jka.js"),
144
+ import("./search-archive-wr38qtkw.js"),
145
145
  import("./expand-attachments-8sxeyj26.js")
146
146
  ]);
147
147
  const pool = new V2StoreReaderPool;
@@ -24,7 +24,7 @@ import {
24
24
  } from "./index-2qtx0q6h.js";
25
25
  import {
26
26
  scheduleAfterBootQuiet
27
- } from "./index-453s1hj6.js";
27
+ } from "./index-hna2sxy8.js";
28
28
  import {
29
29
  configureContextDatabasePragmas2
30
30
  } from "./index-fapenpch.js";
@@ -46,7 +46,7 @@ import {
46
46
  hasPendingMigrations,
47
47
  getMainThreadMigrationBodyCount,
48
48
  runMigrations
49
- } from "./index-gavj3e6h.js";
49
+ } from "./index-e0zdn1p3.js";
50
50
  import {
51
51
  setDatabase,
52
52
  loadToolDefinitionMeasurements,
@@ -56,7 +56,7 @@ import {
56
56
  import {
57
57
  piHarnessKindFromExecutable,
58
58
  getErrorMessage
59
- } from "./index-0th11rhf.js";
59
+ } from "./index-xz5b9t4g.js";
60
60
  import {
61
61
  getOrCreateSessionMeta,
62
62
  updateSessionMeta,
@@ -70,7 +70,7 @@ import {
70
70
  renderMessageByOrdinal2,
71
71
  renderVerboseRange2,
72
72
  renderItemByTag2
73
- } from "./index-6crdakkm.js";
73
+ } from "./index-qz43gkqe.js";
74
74
  import {
75
75
  getLastIndexedOrdinal
76
76
  } from "./index-0t9xfj3x.js";
@@ -129,20 +129,20 @@ import {
129
129
  unregisterProjectEmbedding2,
130
130
  getProjectEmbeddingSnapshot2,
131
131
  embedTextForProject2
132
- } from "./index-0bmsfzqf.js";
132
+ } from "./index-3g1wy4z9.js";
133
133
  import {
134
134
  directoryHasGitMetadata,
135
135
  resolveProjectIdentityForSession,
136
136
  normalizeStoredProjectPath,
137
137
  storedPathBelongsToIdentity
138
- } from "./index-453s1hj6.js";
138
+ } from "./index-hna2sxy8.js";
139
139
  import {
140
140
  createUnifiedSearchDiagnostics2,
141
141
  parseIdShapedQuery2,
142
142
  resolveMemoriesByIdsForSearch2,
143
143
  unifiedSearch2,
144
144
  formatSearchResults2
145
- } from "./index-pz85rpzf.js";
145
+ } from "./index-47g3pgzk.js";
146
146
  import {
147
147
  resolveOpenCodeDbPath,
148
148
  assertOpenCodeStoreGeneration
@@ -159,7 +159,7 @@ import {
159
159
  resolveStoredPathWorkspaceIdentity,
160
160
  storedPathBelongsToWorkspace,
161
161
  sourceNameForMemory
162
- } from "./index-gavj3e6h.js";
162
+ } from "./index-e0zdn1p3.js";
163
163
  import {
164
164
  getNoteByIdInScope,
165
165
  getNotes,
@@ -170,7 +170,7 @@ import {
170
170
  updateNote,
171
171
  dismissNotes,
172
172
  dismissNote
173
- } from "./index-k7a8x7ba.js";
173
+ } from "./index-nmmge3j6.js";
174
174
  import {
175
175
  isMarkerCandidateBasisCurrent2,
176
176
  invalidateMarkerCandidateBasis2,
@@ -2928,7 +2928,7 @@ import { dirname as dirname4, isAbsolute as isAbsolute3, resolve as resolve2 } f
2928
2928
  var CTX_REDUCE_LIGHT_DESCRIPTION = `Stamp an item as no longer needed for the work ahead. Not a delete: stamping QUEUES it, the item stays readable until Magic Context clears stamped items in one sweep, newest tags are protected, and a cleared item goes to the archive (recent: a [dropped §N§] placeholder; older: removed) recoverable via ctx_expand(tag=N). The question is "does this need to stay on my desk for what comes next?" — a file you keep editing stays, the grep that found it goes. Stamp used reads/searches/outputs, acted-on build/test output, redundant dumps, extracted pasted payloads; keep user messages, your own text, unresolved errors, raw evidence, exact wording that may matter. Look at each tag; never blanket-stamp "1-50". Grammar: "3-5", "1,2,9", "1-5,8,12-15".`;
2929
2929
  var CTX_EXPAND_LIGHT_DESCRIPTION = "Recover one item with tag=N (a §N§ or dropped placeholder number), not a message ordinal; text or one tool call with full input/output. message=N and start/end are whole-message ordinals from history/search, never tag numbers. Recover raw conversation behind a <session-history> heading or around a ctx_search hit: ctx_expand(start, end) returns [N] U:/A: lines (~15K-token cap; oversized ranges return the head and where to continue). verbose=true lists messages with per-part previews to pick one; message=N returns that message in full, including a tool output released with ctx_reduce. Ranges after the last compartment are your live tail, not expandable.";
2930
2930
  var CTX_NOTE_LIGHT_DESCRIPTION = 'Session notes are pending intentions: work you intend to return to, with findings attached ("take a note" always qualifies). Not active steps, an executing plan, or restart insurance; a record of how things stand (world-state, a design at a point in time) with nothing you intend to do about it — that goes stale silently; a fact worth keeping is memory, the rest is nothing. First line = title (<80 chars). write saves; read lists rows (note_ids for bodies); update changes one; dismiss retires 1–50. Dismiss a note when its work lands or is abandoned; a queue you never dismiss from stops being read. surface_condition parks it until an outside check against repo files, git, GitHub or the web holds.';
2931
- var CTX_MEMORY_LIGHT_DESCRIPTION = "Durable facts about this project, shared with every agent on it and kept for the months this work lasts; active ones are already in <project-memory> as `#id: fact`. Write one standalone fact when it must not have to be found again — a rule, an architecture fact, a constraint, a config value, a naming convention — especially what cost you turns. A pending intention with evidence is ctx_note, not memory. write (content + category); update one id (content; category optional); archive one or more ids (reason optional); merge two or more ids (content); get 1–20 ids in any status.";
2931
+ var CTX_MEMORY_LIGHT_DESCRIPTION = "Durable facts about this project, shared with every agent and kept for the months this work lasts; active ones are already in <project-memory> as `#id: fact`. Write one standalone fact you must not have to find again — a rule, an architecture fact, a constraint, a config value, a naming convention — especially what cost you turns. A pending intention with evidence is ctx_note, not memory. write (content + category); update one id (content + category); archive one or more ids (reason optional); merge 2+ distinct same-category ids (content); get 1–20 ids in any status.";
2932
2932
  var CTX_SEARCH_LIGHT_DESCRIPTION = 'Search the archive — everything that ever happened here that is not on your desk: memories not in <project-memory>, compacted conversation, commits, notes. Phrase query as a natural-language question carrying the exact terms you expect ("where is the opencode source code path?", "why did we choose SQLite over postgres?", "how does the dreamer lease work?") — a keyword stack finds less. Sources (omit for all): memory (rules, conventions), message (compacted conversation; hits carry ordinals for ctx_expand), git_commit (when did this change), primer (reusable project Q&A the dreamer distils from recurring questions), note (parked follow-ups). Memory ids alone (`#7234`) resolve directly. from/to restrict every source to an inclusive UTC date range.';
2933
2933
 
2934
2934
  // ../plugin/src/shared/prompt-surface-runtime.ts
@@ -7971,9 +7971,9 @@ var FULL_PARAMETER_DESCRIPTIONS = {
7971
7971
  },
7972
7972
  ctx_memory: {
7973
7973
  action: "write | update | archive | merge | get",
7974
- content: "The memory text — one standalone fact (write, update, merge). Archive and get take an empty string.",
7975
- category: "Kind of fact: the new fact's kind for write; on update/merge, the memory's current category to keep it. Archive and get ignore it.",
7976
- ids: "Memory ids from <project-memory>: one for update, one or more for archive, two or more for merge, 1–20 for get. Write takes an empty list.",
7974
+ content: "Send on every call — the memory text for write, update and merge; pass an empty string for archive and get.",
7975
+ category: "Send on every call — the fact's kind for write; on update/merge, the memory's current category to keep it; archive and get ignore it, so pass any valid category.",
7976
+ ids: "Send on every call — one id for update, one or more for archive, two or more distinct ids of memories in the same category for merge, 1–20 for get; write takes an empty list.",
7977
7977
  reason: "Why it is being archived (optional)."
7978
7978
  },
7979
7979
  ctx_search: {
@@ -8006,9 +8006,9 @@ var LIGHT_PARAMETER_DESCRIPTIONS = {
8006
8006
  },
8007
8007
  ctx_memory: {
8008
8008
  action: "write | update | archive | merge | get",
8009
- content: "One standalone fact (write, update, merge). Archive and get: empty string.",
8010
- category: "Kind of fact (write; on update/merge pass the current category to keep it). Archive and get ignore it.",
8011
- ids: "Ids from <project-memory>: one for update, 1+ for archive, 2+ for merge, 1–20 for get. Write: empty list.",
8009
+ content: "Send on every call: the fact (write, update, merge); empty string for archive/get.",
8010
+ category: "Send on every call: kind for write; current category for update/merge; any category for archive/get (ignored).",
8011
+ ids: "Send on every call: one id for update, 1+ for archive, 2+ distinct same-category ids for merge, 1–20 for get; write: empty list.",
8012
8012
  reason: "Why it is archived (optional)."
8013
8013
  },
8014
8014
  ctx_search: {
@@ -8677,10 +8677,11 @@ Your active memories are already in <project-memory> as \`#id: fact\` lines. Wri
8677
8677
 
8678
8678
  Actions:
8679
8679
  - write: new memory (content + category).
8680
- - update: rewrite one memory whose fact changed (ids: [one], content; category optional to recategorize).
8680
+ - update: rewrite one memory whose fact changed (ids: [one], content; category: the current one to keep, a new one to recategorize).
8681
8681
  - archive: retire wrong or obsolete memories (ids: [one or more], optional reason).
8682
- - merge: collapse duplicates into one (ids: [two or more], content).
8682
+ - merge: collapse duplicates into one (ids: [two or more distinct ids of memories in the same category], content).
8683
8683
  - get: fetch by id (ids: 1–20), readable in every status.
8684
+ The call form that works on every host sends action, content, category and ids every time: argument-dropping providers only emit required fields. For get and archive pass content="" and any valid category; for write pass ids=[].
8684
8685
  Examples: category="CONFIG_VALUES", content="OpenCode source is at ~/Work/OSS/opencode" · category="CONSTRAINTS", content="Dashboard Tauri build needs RGBA PNGs, not grayscale"`;
8685
8686
 
8686
8687
  // ../plugin/src/tools/ctx-memory/verification-recording.ts
@@ -8709,13 +8710,13 @@ var ParamsShape = {
8709
8710
  description: "write | update | archive | merge | get"
8710
8711
  }),
8711
8712
  content: String2({
8712
- description: "The memory text — one standalone fact (write, update, merge)."
8713
+ description: "Send on every call — the memory text for write, update and merge; pass an empty string for archive and get."
8713
8714
  }),
8714
8715
  category: Union(V2_MEMORY_CATEGORIES.map((c) => Literal(c)), {
8715
- description: "Kind of fact (required for write; on update/merge, pass the memory's current category to keep it)."
8716
+ description: "Send on every call — the fact's kind for write; on update/merge, the memory's current category to keep it; archive and get ignore it, so pass any valid category."
8716
8717
  }),
8717
8718
  ids: _Array_(Number2(), {
8718
- description: "Memory ids from <project-memory>: one for update, one or more for archive, two or more for merge, 1–20 for get."
8719
+ description: "Send on every call — one id for update, one or more for archive, two or more distinct ids of memories in the same category for merge, 1–20 for get; write takes an empty list."
8719
8720
  }),
8720
8721
  reason: Optional(String2({
8721
8722
  description: "Why it is being archived (optional)."
@@ -8723,7 +8724,7 @@ var ParamsShape = {
8723
8724
  };
8724
8725
  var ListParamsSchema = _Object_({
8725
8726
  category: Optional(Union(V2_MEMORY_CATEGORIES.map((category) => Literal(category)), {
8726
- description: "Kind of fact (required for write; on update/merge optional, omitted keeps the current category)."
8727
+ description: "Filter listed memories to this category (optional)."
8727
8728
  })),
8728
8729
  limit: Optional(Number2({ description: "Max results for list (default 10)." }))
8729
8730
  }, { additionalProperties: true });
package/dist/index.js CHANGED
@@ -166,7 +166,7 @@ import {
166
166
  registerTodoStateLifecycle,
167
167
  syncCtxMemoryToolEnabled,
168
168
  registerMagicContextTools
169
- } from "./index-5009ew3c.js";
169
+ } from "./index-y573dt51.js";
170
170
  import"./index-4knyh1kt.js";
171
171
  import {
172
172
  canonicalModelIdentity,
@@ -198,6 +198,7 @@ import {
198
198
  pruneMissingProjectIdentities,
199
199
  setHomeProjectPermission,
200
200
  ProjectIdentityError,
201
+ directoryFallback,
201
202
  resolveProjectIdentityStrict,
202
203
  isUserHomeDirectory,
203
204
  resolveProjectIdentity,
@@ -205,7 +206,7 @@ import {
205
206
  resolveProjectIdentityForSession,
206
207
  beginBootQuietPeriod,
207
208
  scheduleAfterBootQuiet
208
- } from "./index-453s1hj6.js";
209
+ } from "./index-hna2sxy8.js";
209
210
  import {
210
211
  detectThinkingBindingMismatch,
211
212
  detectLatestTurnThinkingMismatch,
@@ -469,7 +470,7 @@ import {
469
470
  openCurrentDatabase,
470
471
  openDatabaseAsync,
471
472
  closeDatabase
472
- } from "./index-0th11rhf.js";
473
+ } from "./index-xz5b9t4g.js";
473
474
  import {
474
475
  LkgRecoveryFenceError,
475
476
  clearLkgFenceProcessState,
@@ -599,7 +600,7 @@ import {
599
600
  getSourceContents,
600
601
  recordSubagentInvocation,
601
602
  getLatestHistorianInvocationId
602
- } from "./index-6crdakkm.js";
603
+ } from "./index-qz43gkqe.js";
603
604
  import {
604
605
  resolveOpenCodeDbPath,
605
606
  assertOpenCodeStoreGeneration,
@@ -666,7 +667,7 @@ import {
666
667
  getLegacyProtectedTailStartOrdinal2,
667
668
  readSessionChunk2
668
669
  } from "./index-hpbdnbtf.js";
669
- import"./index-nvh6d3bz.js";
670
+ import"./index-qky62xze.js";
670
671
  import {
671
672
  formatSynapseLaneDescriptor
672
673
  } from "./index-5rcjs14a.js";
@@ -689,7 +690,7 @@ import {
689
690
  markGitSweepSuccessAndRelease,
690
691
  parkGitSweepNonIndexable,
691
692
  releaseGitSweepLease
692
- } from "./index-79xfn84y.js";
693
+ } from "./index-gdy08gn6.js";
693
694
  import {
694
695
  embedPauseBySession,
695
696
  embedRunStateBySession,
@@ -720,7 +721,7 @@ import {
720
721
  expandWorkspaceIdentitySetWithAliases,
721
722
  sourceNameForMemory,
722
723
  computeWorkspaceEpochFingerprint
723
- } from "./index-gavj3e6h.js";
724
+ } from "./index-e0zdn1p3.js";
724
725
  import {
725
726
  configureContextDatabasePragmas2
726
727
  } from "./index-fapenpch.js";
@@ -745,7 +746,7 @@ import {
745
746
  createPrimer,
746
747
  updatePrimerSupport,
747
748
  updatePrimerAnswer
748
- } from "./index-k7a8x7ba.js";
749
+ } from "./index-nmmge3j6.js";
749
750
  import {
750
751
  setEmbeddingSessionBusy2,
751
752
  isEmbeddingHostBusy2
@@ -769,6 +770,7 @@ import {
769
770
  updateMemoryVerification2,
770
771
  setMemoryClassification2,
771
772
  archiveMemory2,
773
+ getMemoryCount2,
772
774
  getMemoryCountsByStatus2
773
775
  } from "./index-29nw7n1r.js";
774
776
  import {
@@ -776,7 +778,7 @@ import {
776
778
  } from "./index-yhzhdp3m.js";
777
779
  import {
778
780
  pushNotification2
779
- } from "./index-q1yc6bs0.js";
781
+ } from "./index-7thk2cwt.js";
780
782
  import {
781
783
  getCachedLocalEmbeddingPooling
782
784
  } from "./index-txcs0vnj.js";
@@ -797,7 +799,7 @@ import {
797
799
  embedSessionCompartmentChunks2,
798
800
  getEmbeddingCoverageStatus2,
799
801
  getAutoEmbeddingSessionCoverage2
800
- } from "./index-0bmsfzqf.js";
802
+ } from "./index-3g1wy4z9.js";
801
803
  import {
802
804
  USER_FACING_FAILURES,
803
805
  renderUserFacingFailure,
@@ -832,8 +834,8 @@ import {
832
834
  scheduleClearAndReindex,
833
835
  clearSessionTracking,
834
836
  createAutoSearchDiagnostics
835
- } from "./index-pz85rpzf.js";
836
- import"./index-5tkveh4p.js";
837
+ } from "./index-47g3pgzk.js";
838
+ import"./index-k8xz22jc.js";
837
839
  import"./index-3s39a1md.js";
838
840
  import {
839
841
  DREAMER_PRIMER_INVESTIGATOR_ALLOWED_TOOLS,
@@ -866,7 +868,7 @@ import {
866
868
  } from "./index-pdrberjp.js";
867
869
  import"./index-71rg8j43.js";
868
870
  import"./index-8d2z6503.js";
869
- import"./index-hnvq96j6.js";
871
+ import"./index-wtqv3vha.js";
870
872
  import"./index-fvfq9gva.js";
871
873
  import {
872
874
  __toESM
@@ -3619,7 +3621,7 @@ function startHostStallProfilerSwitch() {
3619
3621
  // package.json
3620
3622
  var package_default = {
3621
3623
  name: "@cortexkit/pi-magic-context",
3622
- version: "0.49.80",
3624
+ version: "0.49.82",
3623
3625
  type: "module",
3624
3626
  description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
3625
3627
  main: "dist/index.js",
@@ -24341,6 +24343,79 @@ function commitPiCompactionModeRecord(db, sessionId, record) {
24341
24343
  // src/context-handler.ts
24342
24344
  import * as crypto3 from "node:crypto";
24343
24345
 
24346
+ // ../plugin/src/features/magic-context/memory/identity-merge-command.ts
24347
+ var IDENTITY_MERGE_COMMAND = "npx @cortexkit/magic-context@latest doctor merge-identities";
24348
+ var IDENTITY_MERGE_PREVIEW_HINT = "It shows what would move. Add --apply to move them.";
24349
+ function shellArg(value, platform) {
24350
+ if (/^[\w.:/-]+$/.test(value))
24351
+ return value;
24352
+ return platform === "win32" ? `"${value}"` : `'${value.replaceAll("'", "'\\''")}'`;
24353
+ }
24354
+ function identityMergeCommand(from, to, platform = process.platform) {
24355
+ return `${IDENTITY_MERGE_COMMAND} --from ${shellArg(from, platform)} --to ${to ? shellArg(to, platform) : '"DESTINATION_IDENTITY"'}`;
24356
+ }
24357
+
24358
+ // ../plugin/src/features/magic-context/memory/project-binding-notice.ts
24359
+ var observedBindings = new WeakMap;
24360
+ function bindingLog(harness, directory, old, identity, memories) {
24361
+ return `project binding changed harness=${harness} cwd=${directory || "unknown"} old=${old ?? "none"} new=${identity} memories=${memories}`;
24362
+ }
24363
+ function observeSessionProjectBinding(db, sessionId, identity, directory, notify) {
24364
+ const change = recordSessionProjectIdentity(db, sessionId, identity);
24365
+ const harness = getHarness2();
24366
+ let observations = observedBindings.get(db);
24367
+ if (!observations) {
24368
+ observations = new BoundedSessionMap(1000);
24369
+ observedBindings.set(db, observations);
24370
+ }
24371
+ const key = `${harness}\x00${sessionId}`;
24372
+ const last = observations.get(key);
24373
+ const noticed = last?.noticed ?? new Set;
24374
+ const observation = {
24375
+ directory,
24376
+ noticed,
24377
+ warning: change ? undefined : last?.warning
24378
+ };
24379
+ observations.set(key, observation);
24380
+ const old = change?.previousProjectPath;
24381
+ if (!change || !old && harness !== "pi" && harness !== "omp")
24382
+ return;
24383
+ const memories = old ? getMemoryCount2(db, old) : 0;
24384
+ const binding = bindingLog(harness, directory, old, identity, memories);
24385
+ if (!old || !memories) {
24386
+ sessionLog2(sessionId, binding);
24387
+ return;
24388
+ }
24389
+ const oldDirectory = [last?.directory, directory].find((path) => path && directoryFallback(path) === old);
24390
+ const location = oldDirectory ? `the old folder (${oldDirectory})` : `the old project (${old})`;
24391
+ let guidance;
24392
+ if (old.startsWith("dir:") && /^(dir|git):/.test(identity)) {
24393
+ guidance = `Review the merge first:
24394
+ ${identityMergeCommand(oldDirectory ?? old, identity)}
24395
+ ${IDENTITY_MERGE_PREVIEW_HINT}`;
24396
+ } else if (old.startsWith("git:") && identity.startsWith("dir:")) {
24397
+ guidance = "A repository's memories cannot be merged into a folder project.";
24398
+ } else {
24399
+ guidance = "Run `npx @cortexkit/magic-context@latest doctor` to see how these memories can be merged.";
24400
+ }
24401
+ const count = `${memories} ${memories === 1 ? "memory" : "memories"}`;
24402
+ observation.warning = `${count} stayed under this session's previous project. Nothing was moved.
24403
+ ${guidance}`;
24404
+ if (noticed.has(old)) {
24405
+ sessionLog2(sessionId, binding);
24406
+ return;
24407
+ }
24408
+ noticed.add(old);
24409
+ const notice = `This session changed projects. ${count} stayed with ${location}; nothing moved. ${guidance}`;
24410
+ sessionLog2(sessionId, `${binding} notice=${JSON.stringify(notice)}`);
24411
+ try {
24412
+ notify?.(notice);
24413
+ } catch {}
24414
+ }
24415
+ function getProjectBindingWarning(db, sessionId) {
24416
+ return observedBindings.get(db)?.peek(`${getHarness2()}\x00${sessionId}`)?.warning;
24417
+ }
24418
+
24344
24419
  // ../plugin/src/hooks/magic-context/event-resolvers.ts
24345
24420
  var DEFAULT_CONTEXT_LIMIT = 200000;
24346
24421
  var WRAPUP_WINDOW_UNAVAILABLE = "Cannot run /ctx-wrapup: the model's context window is unknown. Select a model with a configured context window or send a message with that model, then retry.";
@@ -34306,7 +34381,7 @@ function extractToastTitle(text) {
34306
34381
  }
34307
34382
  async function sendStatusNotification(_client, sessionId, text, params) {
34308
34383
  try {
34309
- const { pushNotification } = await importPluginModule(() => import("./rpc-notifications-gm1mdpwh.js"));
34384
+ const { pushNotification } = await importPluginModule(() => import("./rpc-notifications-889zvhn2.js"));
34310
34385
  pushNotification("toast", {
34311
34386
  title: extractToastTitle(text),
34312
34387
  message: text,
@@ -48788,7 +48863,7 @@ function trackSessionForProject(projectIdentity, sessionId) {
48788
48863
  function isContextHandlerSessionActive(sessionId) {
48789
48864
  return activeContextHandlerSessions.has(sessionId);
48790
48865
  }
48791
- function updateSessionProjectTracking(sessionId, projectIdentity, db, observedCwd) {
48866
+ function updateSessionProjectTracking(sessionId, projectIdentity, db, observedCwd, notify) {
48792
48867
  if (!projectIdentity)
48793
48868
  return;
48794
48869
  const prev = lastSeenProjectIdentityBySession.get(sessionId);
@@ -48801,11 +48876,8 @@ function updateSessionProjectTracking(sessionId, projectIdentity, db, observedCw
48801
48876
  }
48802
48877
  if (db && persistedProjectIdentityBySession.get(sessionId) !== projectIdentity) {
48803
48878
  try {
48804
- const change = recordSessionProjectIdentity(db, sessionId, projectIdentity);
48879
+ observeSessionProjectBinding(db, sessionId, projectIdentity, observedCwd ?? "", notify);
48805
48880
  persistedProjectIdentityBySession.set(sessionId, projectIdentity);
48806
- if (change) {
48807
- sessionLog2(sessionId, `project binding changed harness=${getHarness2()} cwd=${observedCwd ?? "unknown"} old=${change.previousProjectPath ?? "none"} new=${change.projectPath}`);
48808
- }
48809
48881
  } catch (error) {
48810
48882
  const now = Date.now();
48811
48883
  const lastLoggedAt = sessionProjectBindingFailureLogAtBySession.get(sessionId);
@@ -50526,7 +50598,7 @@ function registerPiContextHandler(pi, baseOptions) {
50526
50598
  }));
50527
50599
  assertCurrentPass();
50528
50600
  const historyHead = sessionMetaForUsage.isSubagent ? undefined : options.injection;
50529
- updateSessionProjectTracking(sessionId, projectIdentity, options.db, projectDirectory);
50601
+ updateSessionProjectTracking(sessionId, projectIdentity, options.db, projectDirectory, ctx.hasUI ? (text) => ctx.ui.notify(text, "warning") : undefined);
50530
50602
  const lkgInputIdByRef = new Map;
50531
50603
  for (const input of lkgPassSnapshot.inputs)
50532
50604
  lkgInputIdByRef.set(event.messages[input.messageIndex], input.id);
@@ -55462,6 +55534,10 @@ function renderUserStatusSummary(summary, style) {
55462
55534
  for (const warning of summary.hiddenVariantWarnings ?? []) {
55463
55535
  lines.push(style === "markdown" ? `- **Warning:** ${warning}` : `Warning: ${warning}`);
55464
55536
  }
55537
+ if (summary.projectBindingWarning) {
55538
+ const label = style === "markdown" ? "- **Warning:**" : "Warning:";
55539
+ lines.push(`${label} ${summary.projectBindingWarning}`);
55540
+ }
55465
55541
  for (const warning of summary.warnings) {
55466
55542
  lines.push(style === "markdown" ? `- **Warning:** ${renderUserFacingFailure(warning)}` : `Warning: ${renderUserFacingFailure(warning)}`);
55467
55543
  }
@@ -55644,6 +55720,7 @@ function checkStatusViewSource(candidate) {
55644
55720
  compactionEnabled: optional.read("compactionEnabled", isBoolean),
55645
55721
  warnings: optional.readArray("warnings", isUserFacingFailureKey),
55646
55722
  hiddenVariantWarnings: optional.readArray("hiddenVariantWarnings", isString),
55723
+ projectBindingWarning: optional.read("projectBindingWarning", isString),
55647
55724
  unconfirmedMigrationHolders: optional.read("unconfirmedMigrationHolders", isUnconfirmedMigrationHolders)
55648
55725
  };
55649
55726
  return { ok: true, source, ignoredFields: optional.ignored };
@@ -56111,6 +56188,7 @@ function warningBlock(source) {
56111
56188
  }
56112
56189
  ] : [],
56113
56190
  ...(source.hiddenVariantWarnings ?? []).map((text) => ({ text, tone: "warning" })),
56191
+ ...source.projectBindingWarning ? [{ text: source.projectBindingWarning, tone: "warning" }] : [],
56114
56192
  ...source.configReloadFailure ? [
56115
56193
  {
56116
56194
  text: `Config reload failed ${source.configReloadFailure.path}: ${source.configReloadFailure.message}`,
@@ -56413,6 +56491,7 @@ function formatPiStatusSummary(s) {
56413
56491
  tokens: s.tailHygiene?.u ?? 0
56414
56492
  },
56415
56493
  memoryCount: s.memoryCount,
56494
+ projectBindingWarning: s.projectBindingWarning,
56416
56495
  noteCount: s.sessionNoteCount + s.readySmartNoteCount,
56417
56496
  embedding: s.embedding,
56418
56497
  warnings: piStatusWarnings(s),
@@ -56845,6 +56924,7 @@ function buildStatusDetail(pi, ctx, deps, sessionId, state, host = readStatusHos
56845
56924
  return last ? `${last.startMessage}-${last.endMessage}` : null;
56846
56925
  })(),
56847
56926
  memoryCount: memoryImportanceHistogram.total,
56927
+ projectBindingWarning: getProjectBindingWarning(deps.db, sessionId),
56848
56928
  memoryBlockCount,
56849
56929
  memoryImportanceHistogram,
56850
56930
  sessionNoteCount: safeRead(() => getNotes(deps.db, {
@@ -10,14 +10,14 @@ import {
10
10
  import"./index-135e8hvg.js";
11
11
  import {
12
12
  runMigrationsWithRetry
13
- } from "./index-gavj3e6h.js";
13
+ } from "./index-e0zdn1p3.js";
14
14
  import"./index-jhmz9tgv.js";
15
15
  import"./index-n0zjvs3h.js";
16
- import"./index-453s1hj6.js";
16
+ import"./index-hna2sxy8.js";
17
17
  import {
18
18
  setSqlitePragmaConfig,
19
19
  initializeDatabase
20
- } from "./index-0th11rhf.js";
20
+ } from "./index-xz5b9t4g.js";
21
21
  import"./index-fapenpch.js";
22
22
  import"./index-3bb24eb6.js";
23
23
  import"./index-8sqebjzk.js";
@@ -36,16 +36,16 @@ import {
36
36
  sweepAllRegisteredProjects2,
37
37
  _setTestProviderFactoryForProject2,
38
38
  _resetProjectEmbeddingRegistryForTests2
39
- } from "./index-0bmsfzqf.js";
39
+ } from "./index-3g1wy4z9.js";
40
40
  import"./index-9p40dgkm.js";
41
41
  import"./index-hgd00nas.js";
42
42
  import"./index-yhzhdp3m.js";
43
- import"./index-79xfn84y.js";
43
+ import"./index-gdy08gn6.js";
44
44
  import"./index-cxczethe.js";
45
45
  import"./index-txcs0vnj.js";
46
46
  import"./index-5rcjs14a.js";
47
47
  import"./index-vcegxfwg.js";
48
- import"./index-453s1hj6.js";
48
+ import"./index-hna2sxy8.js";
49
49
  import"./index-ghp32f9m.js";
50
50
  import"./index-xjhq27z9.js";
51
51
  import"./index-wfqysrwq.js";
@@ -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-zndhp4c4.js");
22
+ const { serveV2ArchiveReads } = await import("./v2-archive-reader-8m9mw6sv.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-661vc3fb.js");
54
+ const { renderSearchArchive } = await import("./search-archive-wr38qtkw.js");
55
55
  const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-0tytrjye.js");
56
56
  const archive = input.searchArchive;
57
57
  let raw;
@@ -3,22 +3,22 @@ import {
3
3
  renderVerboseRange2,
4
4
  renderVerboseRangeForTool2,
5
5
  renderItemByTag2
6
- } from "./index-6crdakkm.js";
7
- import"./index-k7a8x7ba.js";
6
+ } from "./index-qz43gkqe.js";
7
+ import"./index-nmmge3j6.js";
8
8
  import"./index-0t9xfj3x.js";
9
9
  import"./index-hgd00nas.js";
10
- import"./index-nvh6d3bz.js";
10
+ import"./index-qky62xze.js";
11
11
  import"./index-cxczethe.js";
12
12
  import"./index-hpbdnbtf.js";
13
13
  import"./index-nh4srq1p.js";
14
14
  import"./index-6x556c2q.js";
15
15
  import"./index-5rcjs14a.js";
16
16
  import"./index-vcegxfwg.js";
17
- import"./index-0th11rhf.js";
17
+ import"./index-xz5b9t4g.js";
18
18
  import"./index-fapenpch.js";
19
- import"./index-gavj3e6h.js";
19
+ import"./index-e0zdn1p3.js";
20
20
  import"./index-135e8hvg.js";
21
- import"./index-453s1hj6.js";
21
+ import"./index-hna2sxy8.js";
22
22
  import"./index-ghp32f9m.js";
23
23
  import"./index-3bb24eb6.js";
24
24
  import"./index-jhmz9tgv.js";
@@ -1,16 +1,18 @@
1
1
  import {
2
2
  registerNotificationSink2,
3
+ pushLiveNotification2,
3
4
  pushNotification2,
4
5
  acknowledgeNotifications2,
5
6
  __resetNotificationStateForTests2,
6
7
  drainNotifications2,
7
8
  isTuiConnected2
8
- } from "./index-q1yc6bs0.js";
9
+ } from "./index-7thk2cwt.js";
9
10
  export {
10
11
  __resetNotificationStateForTests2 as __resetNotificationStateForTests,
11
12
  acknowledgeNotifications2 as acknowledgeNotifications,
12
13
  drainNotifications2 as drainNotifications,
13
14
  isTuiConnected2 as isTuiConnected,
15
+ pushLiveNotification2 as pushLiveNotification,
14
16
  pushNotification2 as pushNotification,
15
17
  registerNotificationSink2 as registerNotificationSink
16
18
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  renderSearchArchive2
3
3
  } from "./index-fvfq9gva.js";
4
- import"./index-hnvq96j6.js";
4
+ import"./index-wtqv3vha.js";
5
5
  import"./index-8d2z6503.js";
6
6
  import"./index-hpbdnbtf.js";
7
7
  import"./index-nh4srq1p.js";
@@ -5,17 +5,17 @@ import {
5
5
  resolveMemoriesByIdsForSearch2,
6
6
  unifiedSearch2,
7
7
  formatSearchResults2
8
- } from "./index-pz85rpzf.js";
9
- import"./index-k7a8x7ba.js";
8
+ } from "./index-47g3pgzk.js";
9
+ import"./index-nmmge3j6.js";
10
10
  import"./index-0t9xfj3x.js";
11
11
  import"./index-8d2z6503.js";
12
- import"./index-5tkveh4p.js";
12
+ import"./index-k8xz22jc.js";
13
13
  import"./index-29nw7n1r.js";
14
- import"./index-0bmsfzqf.js";
14
+ import"./index-3g1wy4z9.js";
15
15
  import"./index-9p40dgkm.js";
16
16
  import"./index-hgd00nas.js";
17
17
  import"./index-yhzhdp3m.js";
18
- import"./index-79xfn84y.js";
18
+ import"./index-gdy08gn6.js";
19
19
  import"./index-cxczethe.js";
20
20
  import"./index-hpbdnbtf.js";
21
21
  import"./index-nh4srq1p.js";
@@ -23,9 +23,9 @@ import"./index-6x556c2q.js";
23
23
  import"./index-txcs0vnj.js";
24
24
  import"./index-5rcjs14a.js";
25
25
  import"./index-vcegxfwg.js";
26
- import"./index-gavj3e6h.js";
26
+ import"./index-e0zdn1p3.js";
27
27
  import"./index-135e8hvg.js";
28
- import"./index-453s1hj6.js";
28
+ import"./index-hna2sxy8.js";
29
29
  import"./index-ghp32f9m.js";
30
30
  import"./index-jhmz9tgv.js";
31
31
  import"./index-xjhq27z9.js";
@@ -3,7 +3,7 @@ import {
3
3
  RAW_MESSAGE_TYPES2,
4
4
  V2StoreReaderPool2,
5
5
  V2StoreReader2
6
- } from "./index-nvh6d3bz.js";
6
+ } from "./index-qky62xze.js";
7
7
  import"./index-n0zjvs3h.js";
8
8
  import"./index-2qtx0q6h.js";
9
9
  export {
@@ -4,7 +4,7 @@ import"./index-n0zjvs3h.js";
4
4
  import"./index-2qtx0q6h.js";
5
5
  import {
6
6
  RAW_MESSAGE_TYPES2
7
- } from "./index-nvh6d3bz.js";
7
+ } from "./index-qky62xze.js";
8
8
  import {
9
9
  markHostUnservedRow
10
10
  } from "./index-by1bzjcd.js";
@@ -10,11 +10,11 @@ import {
10
10
  import"./index-dnp1jjar.js";
11
11
  import {
12
12
  resolveProjectIdentityForSession
13
- } from "./index-453s1hj6.js";
13
+ } from "./index-hna2sxy8.js";
14
14
  import"./index-2qtx0q6h.js";
15
15
  import {
16
16
  openDatabase
17
- } from "./index-0th11rhf.js";
17
+ } from "./index-xz5b9t4g.js";
18
18
  import"./index-fapenpch.js";
19
19
  import"./index-3bb24eb6.js";
20
20
  import"./index-8sqebjzk.js";
@@ -22,7 +22,7 @@ import"./index-wfqysrwq.js";
22
22
  import"./index-x2n261wp.js";
23
23
  import"./index-xjhq27z9.js";
24
24
  import"./index-ghp32f9m.js";
25
- import"./index-gavj3e6h.js";
25
+ import"./index-e0zdn1p3.js";
26
26
  import"./index-jhmz9tgv.js";
27
27
  import"./index-135e8hvg.js";
28
28
  import"./index-n0zjvs3h.js";
@@ -34,27 +34,27 @@ import {
34
34
  resolvePiHarnessKind,
35
35
  reportSubagentStartupError,
36
36
  registerMagicContextTools
37
- } from "./index-5009ew3c.js";
37
+ } from "./index-y573dt51.js";
38
38
  import"./index-vcegxfwg.js";
39
39
  import"./index-5rcjs14a.js";
40
40
  import"./index-cxczethe.js";
41
41
  import"./index-txcs0vnj.js";
42
- import"./index-0bmsfzqf.js";
42
+ import"./index-3g1wy4z9.js";
43
43
  import"./index-hgd00nas.js";
44
44
  import"./index-9p40dgkm.js";
45
- import"./index-79xfn84y.js";
45
+ import"./index-gdy08gn6.js";
46
46
  import"./index-yhzhdp3m.js";
47
- import"./index-pz85rpzf.js";
48
- import"./index-6crdakkm.js";
47
+ import"./index-47g3pgzk.js";
48
+ import"./index-qz43gkqe.js";
49
49
  import"./index-0t9xfj3x.js";
50
50
  import"./index-nh4srq1p.js";
51
51
  import"./index-6x556c2q.js";
52
- import"./index-nvh6d3bz.js";
53
- import"./index-k7a8x7ba.js";
52
+ import"./index-qky62xze.js";
53
+ import"./index-nmmge3j6.js";
54
54
  import"./index-8d2z6503.js";
55
- import"./index-hnvq96j6.js";
55
+ import"./index-wtqv3vha.js";
56
56
  import"./index-fvfq9gva.js";
57
- import"./index-5tkveh4p.js";
57
+ import"./index-k8xz22jc.js";
58
58
  import"./index-29nw7n1r.js";
59
59
  import"./index-3s39a1md.js";
60
60
  import"./index-1ts77n1b.js";
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  Database2
3
3
  } from "./index-2qtx0q6h.js";
4
- import"./index-453s1hj6.js";
4
+ import"./index-hna2sxy8.js";
5
5
  import"./index-0h2mkab2.js";
6
6
  import"./index-dnp1jjar.js";
7
7
  import"./index-tm11k42a.js";
8
8
  import {
9
9
  LATEST_SUPPORTED_VERSION,
10
10
  getPersistedSchemaVersion
11
- } from "./index-0th11rhf.js";
11
+ } from "./index-xz5b9t4g.js";
12
12
  import"./index-fapenpch.js";
13
13
  import"./index-3bb24eb6.js";
14
14
  import"./index-8sqebjzk.js";
@@ -18,7 +18,7 @@ import {
18
18
  } from "./index-x2n261wp.js";
19
19
  import"./index-xjhq27z9.js";
20
20
  import"./index-ghp32f9m.js";
21
- import"./index-gavj3e6h.js";
21
+ import"./index-e0zdn1p3.js";
22
22
  import {
23
23
  tagRevisionKey
24
24
  } from "./index-jhmz9tgv.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  readV2ArchiveOffThread2,
3
3
  serveV2ArchiveReads2
4
- } from "./index-hnvq96j6.js";
4
+ } from "./index-wtqv3vha.js";
5
5
  import"./index-8sqebjzk.js";
6
6
  import"./index-2qtx0q6h.js";
7
7
  import"./index-x2n261wp.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.49.80",
3
+ "version": "0.49.82",
4
4
  "type": "module",
5
5
  "description": "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",