@cortexkit/pi-magic-context 0.49.31 → 0.49.32

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 +4 -4
  2. package/dist/chunk-embedding-write-worker.js +4 -4
  3. package/dist/{compartment-chunk-embedding-pkk5beqp.js → compartment-chunk-embedding-8c85ebce.js} +1 -1
  4. package/dist/{embedding-backfill-v83xh6e8.js → embedding-backfill-rwfmyvze.js} +3 -3
  5. package/dist/{index-kmk3xpf9.js → index-0gymvr5j.js} +47 -7
  6. package/dist/{index-34e3mm36.js → index-87xkw8xm.js} +6 -4
  7. package/dist/{index-4nny4r40.js → index-9xd7qveg.js} +1 -1
  8. package/dist/{index-g026ztby.js → index-c474g0gj.js} +4 -18
  9. package/dist/{index-2nryd8ye.js → index-d0n9yjnc.js} +13 -11
  10. package/dist/{index-sr1ss4f8.js → index-d5q1q700.js} +1 -1
  11. package/dist/{index-v40sm8q6.js → index-drmr22ac.js} +3 -3
  12. package/dist/{index-bpd654bz.js → index-e59j3yq5.js} +414 -11
  13. package/dist/{index-0x1c054v.js → index-eqw9t2ty.js} +1 -1
  14. package/dist/index-nrzkqte4.js +18 -0
  15. package/dist/{index-0s14xaca.js → index-pb3ea2tq.js} +1 -1
  16. package/dist/{index-xvqcqg0r.js → index-r9y6tbbm.js} +6 -4
  17. package/dist/{index-yddeb86g.js → index-wpazxe9x.js} +64 -3
  18. package/dist/{index-0jykn0dw.js → index-xn5yh0pn.js} +65 -2
  19. package/dist/index.js +84 -314
  20. package/dist/{message-index-bounded-7aw556kv.js → message-index-bounded-n30vk21s.js} +4 -4
  21. package/dist/migration-worker.js +6 -5
  22. package/dist/{project-embedding-registry-wwbhm9rf.js → project-embedding-registry-acqb6be4.js} +2 -2
  23. package/dist/raw-ordinal-warmup-worker.js +3 -3
  24. package/dist/{read-session-chunk-xrymr0pp.js → read-session-chunk-ka6dhc77.js} +3 -3
  25. package/dist/{search-archive-5tmg1jyb.js → search-archive-msy2bczx.js} +4 -4
  26. package/dist/{search-dcdmpc62.js → search-qbxrnnjb.js} +9 -9
  27. package/dist/{storage-tags-9qaasrky.js → storage-tags-6409qq18.js} +2 -2
  28. package/dist/subagent-entry.js +12 -12
  29. package/dist/tag-snapshot-worker-pi.js +5 -5
  30. package/package.json +1 -1
@@ -24,12 +24,12 @@ var [
24
24
  { Database, registerSqliteDiagnosticSink },
25
25
  { log }
26
26
  ] = await Promise.all([
27
- import("./embedding-backfill-v83xh6e8.js"),
27
+ import("./embedding-backfill-rwfmyvze.js"),
28
28
  import("./embedding-cache-7rp4gqzr.js"),
29
29
  import("./storage-memory-0ndn65fm.js"),
30
- import("./project-embedding-registry-wwbhm9rf.js"),
31
- import("./search-dcdmpc62.js"),
32
- import("./compartment-chunk-embedding-pkk5beqp.js"),
30
+ import("./project-embedding-registry-acqb6be4.js"),
31
+ import("./search-qbxrnnjb.js"),
32
+ import("./compartment-chunk-embedding-8c85ebce.js"),
33
33
  import("./embedding-activity-ew6dshfd.js"),
34
34
  import("./harness-9872e0ym.js"),
35
35
  import("./sqlite-v89bj0yy.js"),
@@ -22,7 +22,7 @@ import {
22
22
  recordChunkEmbedBackoff2,
23
23
  loadUnembeddedSessionChunkCandidates2,
24
24
  countUnembeddedSessionCompartments2
25
- } from "./index-kmk3xpf9.js";
25
+ } from "./index-0gymvr5j.js";
26
26
  import {
27
27
  recordSessionProjectIdentity,
28
28
  acquireGitSweepLease,
@@ -33,9 +33,9 @@ import"./index-48twbev2.js";
33
33
  import {
34
34
  LATEST_SUPPORTED_VERSION,
35
35
  enforceSchemaFence
36
- } from "./index-xvqcqg0r.js";
37
- import"./index-0s14xaca.js";
38
- import"./index-g026ztby.js";
36
+ } from "./index-r9y6tbbm.js";
37
+ import"./index-pb3ea2tq.js";
38
+ import"./index-c474g0gj.js";
39
39
  import"./index-135e8hvg.js";
40
40
  import"./index-23t8ryqw.js";
41
41
  import"./index-hqw0rt9k.js";
@@ -24,7 +24,7 @@ import {
24
24
  countSessionCompartmentEmbedCoverage2,
25
25
  countSessionCompartmentEmbedCoveragePolite2,
26
26
  countUnembeddedSessionCompartmentsPolite2
27
- } from "./index-kmk3xpf9.js";
27
+ } from "./index-0gymvr5j.js";
28
28
  import"./index-gwxaz0z5.js";
29
29
  import"./index-bvpar0bg.js";
30
30
  import"./index-6981g1xv.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  ensureMemoryEmbeddings2
3
- } from "./index-4nny4r40.js";
4
- import"./index-0jykn0dw.js";
3
+ } from "./index-9xd7qveg.js";
4
+ import"./index-xn5yh0pn.js";
5
5
  import"./index-9p40dgkm.js";
6
6
  import"./index-yhzhdp3m.js";
7
7
  import"./index-4zemngt7.js";
8
- import"./index-kmk3xpf9.js";
8
+ import"./index-0gymvr5j.js";
9
9
  import"./index-wqpjhx1p.js";
10
10
  import"./index-gwxaz0z5.js";
11
11
  import"./index-ccanzg8p.js";
@@ -14,6 +14,9 @@ import {
14
14
  import {
15
15
  messageFtsOrdinalRangeIsMapped2
16
16
  } from "./index-bvpar0bg.js";
17
+ import {
18
+ isKnownAutocommit
19
+ } from "./index-nrzkqte4.js";
17
20
 
18
21
  // ../plugin/src/features/magic-context/compartment-chunk-embedding.ts
19
22
  import { createHash } from "node:crypto";
@@ -346,15 +349,15 @@ function readDatabaseRevision(db) {
346
349
  if (!statements) {
347
350
  statements = {
348
351
  version: db.prepare("PRAGMA data_version"),
349
- changes: db.prepare("SELECT total_changes() AS changes")
352
+ changes: db.prepare("SELECT total_changes() AS changes, (SELECT schema_version FROM pragma_schema_version) AS schemaVersion")
350
353
  };
351
354
  revisionStatements.set(db, statements);
352
355
  }
353
356
  const version = statements.version.get();
354
357
  const changes = statements.changes.get();
355
- if (typeof version?.data_version !== "number" || typeof changes?.changes !== "number")
358
+ if (typeof version?.data_version !== "number" || typeof changes?.changes !== "number" || typeof changes.schemaVersion !== "number")
356
359
  return null;
357
- return `${version.data_version}:${changes.changes}`;
360
+ return `${version.data_version}:${changes.changes}:${changes.schemaVersion}`;
358
361
  }
359
362
  function sameSearchScope(left, right) {
360
363
  return left.rowCount === right.rowCount && left.maxRowId === right.maxRowId && left.rowIdSum === right.rowIdSum && (left.metadata === right.metadata || [...left.metadata].every(([id, value]) => right.metadata.get(id) === value));
@@ -1198,6 +1201,44 @@ function storedWindowsMatchRecordedSource(db, compartmentId, sourceKey, existing
1198
1201
  }
1199
1202
  var COVERAGE_MEMO_LIMIT = 2048;
1200
1203
  var cachedCoverageWindows = new Map;
1204
+ var cachedCoverageSources = new WeakMap;
1205
+ function coverageSource(db, candidate, modelId, maxInputTokens) {
1206
+ const revision = isKnownAutocommit(db) ? readDatabaseRevision(db) : null;
1207
+ if (revision === null)
1208
+ cachedCoverageSources.delete(db);
1209
+ let cache = cachedCoverageSources.get(db);
1210
+ if (revision !== null && cache?.revision !== revision) {
1211
+ cache = { revision, entries: new Map };
1212
+ cachedCoverageSources.set(db, cache);
1213
+ }
1214
+ const key = JSON.stringify([
1215
+ candidate.id,
1216
+ candidate.sessionId,
1217
+ candidate.startMessage,
1218
+ candidate.endMessage,
1219
+ modelId,
1220
+ maxInputTokens,
1221
+ CHUNKER_VERSION,
1222
+ getTokenEstimatorFingerprint()
1223
+ ]);
1224
+ const cached = cache?.entries.get(key);
1225
+ if (cached)
1226
+ return cached;
1227
+ const mappedText = buildCanonicalChunkTextFromFts2(db, candidate.sessionId, candidate.startMessage, candidate.endMessage);
1228
+ if (mappedText === null)
1229
+ return null;
1230
+ const canonicalText = mappedText || buildCompartmentSummaryFallbackText2(db, candidate.id);
1231
+ const source = {
1232
+ canonicalText,
1233
+ sourceKey: chunkWindowSourceKey2(canonicalText, candidate.startMessage, candidate.endMessage, maxInputTokens)
1234
+ };
1235
+ if (cache && readDatabaseRevision(db) === revision) {
1236
+ if (cache.entries.size >= 8192)
1237
+ cache.entries.delete(cache.entries.keys().next().value);
1238
+ cache.entries.set(key, source);
1239
+ }
1240
+ return source;
1241
+ }
1201
1242
  function memoizedCoverageWindows(candidate, canonicalText, sourceKey, modelId, maxInputTokens) {
1202
1243
  const key = JSON.stringify([candidate.id, sourceKey, modelId]);
1203
1244
  const cached = cachedCoverageWindows.get(key);
@@ -1236,14 +1277,13 @@ function renumberOneBasedChunkWindows(db, candidate, projectPath, modelId, windo
1236
1277
  }).immediate();
1237
1278
  }
1238
1279
  function classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens) {
1239
- const mappedText = buildCanonicalChunkTextFromFts2(db, candidate.sessionId, candidate.startMessage, candidate.endMessage);
1240
- if (mappedText === null)
1280
+ const source = coverageSource(db, candidate, modelId, maxInputTokens);
1281
+ if (source === null)
1241
1282
  return { defect: "deferred", windows: [] };
1242
- const canonicalText = mappedText || buildCompartmentSummaryFallbackText2(db, candidate.id);
1283
+ const { canonicalText, sourceKey } = source;
1243
1284
  if (!canonicalText || chunkEmbedBackoffActive(db, candidate, projectPath, modelId, canonicalText)) {
1244
1285
  return { defect: "deferred", windows: [] };
1245
1286
  }
1246
- const sourceKey = chunkWindowSourceKey2(canonicalText, candidate.startMessage, candidate.endMessage, maxInputTokens);
1247
1287
  const existing = getExistingChunkHashes(db, candidate.id, modelId, projectPath);
1248
1288
  if (storedWindowsMatchRecordedSource(db, candidate.id, sourceKey, existing)) {
1249
1289
  return { defect: null, windows: [], sourceKey, confirmedByRecord: true };
@@ -23,7 +23,7 @@ import {
23
23
  TAG_SELECT_COLUMNS2,
24
24
  getCandidateToolOwners2,
25
25
  pickNearestPriorOwner2
26
- } from "./index-0x1c054v.js";
26
+ } from "./index-eqw9t2ty.js";
27
27
  import {
28
28
  OMO_INTERNAL_INITIATOR_MARKER,
29
29
  isSystemDirective,
@@ -45,9 +45,8 @@ import {
45
45
  prepareCachedStatement2
46
46
  } from "./index-2qtx0q6h.js";
47
47
  import {
48
- stableStringify,
49
- closeQuietly
50
- } from "./index-g026ztby.js";
48
+ stableStringify
49
+ } from "./index-c474g0gj.js";
51
50
  import {
52
51
  resolveOpenCodeDbPath,
53
52
  assertOpenCodeStoreGeneration,
@@ -73,6 +72,9 @@ import {
73
72
  readRawSeedTailFromDb2,
74
73
  readRawSessionBoundaryEndpointsFromDb2
75
74
  } from "./index-6981g1xv.js";
75
+ import {
76
+ closeQuietly
77
+ } from "./index-nrzkqte4.js";
76
78
  import {
77
79
  logSlowWriteTransaction
78
80
  } from "./index-hqw0rt9k.js";
@@ -15,7 +15,7 @@ import {
15
15
  OpenAICompatibleEmbeddingProvider,
16
16
  getProjectEmbeddingSnapshot2,
17
17
  embedBatchForProject2
18
- } from "./index-0jykn0dw.js";
18
+ } from "./index-xn5yh0pn.js";
19
19
  import {
20
20
  isEmbeddingHostBusy2
21
21
  } from "./index-9p40dgkm.js";
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  sessionLog2
3
3
  } from "./index-fgs78jyd.js";
4
+ import {
5
+ isKnownAutocommit
6
+ } from "./index-nrzkqte4.js";
4
7
 
5
8
  // ../plugin/src/shared/stable-json.ts
6
9
  function stableStringify(value, seen = new WeakSet) {
@@ -65,23 +68,6 @@ function jsonHashSink(prefix = "") {
65
68
  return { write, digest: () => (hash >>> 0).toString(16).padStart(8, "0") };
66
69
  }
67
70
 
68
- // ../plugin/src/shared/sqlite-helpers.ts
69
- function closeQuietly(db) {
70
- if (!db)
71
- return;
72
- try {
73
- db.close();
74
- } catch {}
75
- }
76
- function isKnownAutocommit(db) {
77
- const state = db;
78
- try {
79
- return state.inTransaction === false || state.isTransaction === false;
80
- } catch {
81
- return false;
82
- }
83
- }
84
-
85
71
  // ../plugin/src/features/magic-context/storage-schema-helpers.ts
86
72
  var columnCaches = new WeakMap;
87
73
  function readColumnNames(db, table) {
@@ -539,4 +525,4 @@ function deleteTagIdentityRevisions(db, sessionIds) {
539
525
  }
540
526
  }
541
527
 
542
- export { stableStringify, jsonHashSink, closeQuietly, isKnownAutocommit, getTableColumnNames, ensureColumn, healAllNullColumns, observeTemporalDecisions, freezeTemporalDecisions, installV95PerfSchema, tagOrderConstraintIndex, tagRevisionIncarnationSql, tagRevisionCountSql, tagTombstoneOwnerRange, tagTombstoneOwnerKey, tagRevisionKey, tagIdentityRevisionKey, TAG_INSERT_CONFLICT_ROWS, installTagIdentityRevisionTrigger, deleteTagIdentityRevisions };
528
+ export { stableStringify, jsonHashSink, getTableColumnNames, ensureColumn, healAllNullColumns, observeTemporalDecisions, freezeTemporalDecisions, installV95PerfSchema, tagOrderConstraintIndex, tagRevisionIncarnationSql, tagRevisionCountSql, tagTombstoneOwnerRange, tagTombstoneOwnerKey, tagRevisionKey, tagIdentityRevisionKey, TAG_INSERT_CONFLICT_ROWS, installTagIdentityRevisionTrigger, deleteTagIdentityRevisions };
@@ -66,7 +66,7 @@ import {
66
66
  visitRawSessionMessages2,
67
67
  readRawSessionMessageById2,
68
68
  readSessionChunk2
69
- } from "./index-34e3mm36.js";
69
+ } from "./index-87xkw8xm.js";
70
70
  import {
71
71
  isRecord,
72
72
  providerVisibleMessage,
@@ -80,7 +80,7 @@ import {
80
80
  getTagNumberByMessageId2,
81
81
  getTagsBySession2,
82
82
  getTagById2
83
- } from "./index-0x1c054v.js";
83
+ } from "./index-eqw9t2ty.js";
84
84
  import {
85
85
  estimateTokens
86
86
  } from "./index-my0dn413.js";
@@ -93,20 +93,19 @@ import {
93
93
  } from "./index-2qtx0q6h.js";
94
94
  import {
95
95
  stableStringify,
96
- closeQuietly,
97
96
  getTableColumnNames,
98
97
  tagTombstoneOwnerRange,
99
98
  tagTombstoneOwnerKey,
100
99
  tagRevisionKey,
101
100
  tagIdentityRevisionKey,
102
101
  deleteTagIdentityRevisions
103
- } from "./index-g026ztby.js";
102
+ } from "./index-c474g0gj.js";
104
103
  import {
105
104
  piHarnessKindFromExecutable,
106
105
  isPidAlive,
107
106
  readProcessStartTime,
108
107
  getErrorMessage
109
- } from "./index-xvqcqg0r.js";
108
+ } from "./index-r9y6tbbm.js";
110
109
  import {
111
110
  BoundedSessionMap,
112
111
  resolveOpenCodeDbPath,
@@ -127,7 +126,7 @@ import {
127
126
  } from "./index-bvpar0bg.js";
128
127
  import {
129
128
  deleteChunkEmbedBackoffForSession2
130
- } from "./index-kmk3xpf9.js";
129
+ } from "./index-0gymvr5j.js";
131
130
  import {
132
131
  invalidateAutoEmbedSession,
133
132
  drainBackgroundBatches,
@@ -140,10 +139,10 @@ import {
140
139
  unregisterProjectEmbedding2,
141
140
  getProjectEmbeddingSnapshot2,
142
141
  embedTextForProject2
143
- } from "./index-0jykn0dw.js";
142
+ } from "./index-xn5yh0pn.js";
144
143
  import {
145
144
  getLastIndexedOrdinal
146
- } from "./index-yddeb86g.js";
145
+ } from "./index-wpazxe9x.js";
147
146
  import {
148
147
  V2_MEMORY_CATEGORIES,
149
148
  CATEGORY_PRIORITY,
@@ -157,7 +156,7 @@ import {
157
156
  expandWorkspaceIdentitySetWithAliases,
158
157
  resolveStoredPathWorkspaceIdentity,
159
158
  storedPathBelongsToWorkspace
160
- } from "./index-0s14xaca.js";
159
+ } from "./index-pb3ea2tq.js";
161
160
  import {
162
161
  sameProjectDirectory,
163
162
  directoryHasGitMetadata,
@@ -180,7 +179,7 @@ import {
180
179
  resolveMemoriesByIdsForSearch2,
181
180
  unifiedSearch2,
182
181
  formatSearchResults2
183
- } from "./index-bpd654bz.js";
182
+ } from "./index-e59j3yq5.js";
184
183
  import {
185
184
  computeCueContentHash,
186
185
  getMuralCueState,
@@ -211,10 +210,13 @@ import {
211
210
  } from "./index-6wdwv3a6.js";
212
211
  import {
213
212
  renderSearchArchive2
214
- } from "./index-sr1ss4f8.js";
213
+ } from "./index-d5q1q700.js";
215
214
  import {
216
215
  computeNormalizedHash
217
216
  } from "./index-9x1f96r8.js";
217
+ import {
218
+ closeQuietly
219
+ } from "./index-nrzkqte4.js";
218
220
  import {
219
221
  logSlowWriteTransaction
220
222
  } from "./index-hqw0rt9k.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./index-my0dn413.js";
7
7
  import {
8
8
  readRawSessionMessageIdOrdinalsForRange2
9
- } from "./index-34e3mm36.js";
9
+ } from "./index-87xkw8xm.js";
10
10
 
11
11
  // ../plugin/src/tools/ctx-expand/search-archive.ts
12
12
  var archiveReadsOnThisThread = 0;
@@ -3,11 +3,11 @@ import {
3
3
  tagRevisionCountSql,
4
4
  tagRevisionKey,
5
5
  TAG_INSERT_CONFLICT_ROWS
6
- } from "./index-g026ztby.js";
6
+ } from "./index-c474g0gj.js";
7
7
  import {
8
8
  getTagsBySession2,
9
9
  getTagsByNumbers2
10
- } from "./index-0x1c054v.js";
10
+ } from "./index-eqw9t2ty.js";
11
11
  import {
12
12
  inRootAsyncContext2,
13
13
  getSqliteDatabasePath2,
@@ -15,7 +15,7 @@ import {
15
15
  } from "./index-2qtx0q6h.js";
16
16
  import {
17
17
  createFailClosedBlockingError
18
- } from "./index-xvqcqg0r.js";
18
+ } from "./index-r9y6tbbm.js";
19
19
  import {
20
20
  createWorkerShutdown
21
21
  } from "./index-54wmg4rj.js";