@cortexkit/pi-magic-context 0.49.79 → 0.49.81
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.
- package/dist/auto-search-worker.js +2 -2
- package/dist/{embedding-backfill-h1wjzh1n.js → embedding-backfill-arvg2p6f.js} +1 -1
- package/dist/{index-97ay0whg.js → index-5009ew3c.js} +9 -5
- package/dist/{index-gczr1m66.js → index-5tkveh4p.js} +4 -6
- package/dist/{index-55dhgfwp.js → index-pz85rpzf.js} +15 -10
- package/dist/index.js +5 -9
- package/dist/{search-9tg206vb.js → search-vw6ps2me.js} +2 -2
- package/dist/subagent-entry.js +3 -3
- 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-
|
|
30
|
+
import("./embedding-backfill-arvg2p6f.js"),
|
|
31
31
|
import("./embedding-cache-7rp4gqzr.js"),
|
|
32
32
|
import("./storage-memory-0ndn65fm.js"),
|
|
33
33
|
import("./project-embedding-registry-zgzq9ehw.js"),
|
|
34
|
-
import("./search-
|
|
34
|
+
import("./search-vw6ps2me.js"),
|
|
35
35
|
import("./compartment-chunk-embedding-avkyp2df.js"),
|
|
36
36
|
import("./embedding-activity-ew6dshfd.js"),
|
|
37
37
|
import("./harness-9872e0ym.js"),
|
|
@@ -142,7 +142,7 @@ import {
|
|
|
142
142
|
resolveMemoriesByIdsForSearch2,
|
|
143
143
|
unifiedSearch2,
|
|
144
144
|
formatSearchResults2
|
|
145
|
-
} from "./index-
|
|
145
|
+
} from "./index-pz85rpzf.js";
|
|
146
146
|
import {
|
|
147
147
|
resolveOpenCodeDbPath,
|
|
148
148
|
assertOpenCodeStoreGeneration
|
|
@@ -704,6 +704,8 @@ var OUTPUT_RESERVE_CAP_RATIO2 = 0.25;
|
|
|
704
704
|
var outputReserveConfig;
|
|
705
705
|
var reserveClampLogSeen = new Set;
|
|
706
706
|
var apiCache = null;
|
|
707
|
+
var v2DraftModelLimits = new Map;
|
|
708
|
+
var v2DraftModelLimitLogged = new Set;
|
|
707
709
|
var persistSeedLoaded = false;
|
|
708
710
|
function persistFilePath() {
|
|
709
711
|
return join(getMagicContextStorageDir(), `model-context-limits-${getHarness2()}.json`);
|
|
@@ -802,9 +804,12 @@ function resolveLimit(limit, providerID, modelID, reserveConfig = outputReserveC
|
|
|
802
804
|
}
|
|
803
805
|
return Math.floor(context - reserve);
|
|
804
806
|
}
|
|
805
|
-
function
|
|
807
|
+
function windowMetadata(providerID, modelID) {
|
|
806
808
|
loadPersistedApiCacheOnce();
|
|
807
|
-
|
|
809
|
+
return (getHarness2() === "opencode2" ? v2DraftModelLimits.get(`${providerID}/${modelID}`) : undefined) ?? lookupMetadataWithTagFallback(apiCache, providerID, modelID);
|
|
810
|
+
}
|
|
811
|
+
function getSdkWindowGeometry(providerID, modelID, detectedContextLimit, options) {
|
|
812
|
+
const metadata = windowMetadata(providerID, modelID);
|
|
808
813
|
if (!metadata)
|
|
809
814
|
return;
|
|
810
815
|
const rawContext = metadata.contextLimit ?? metadata.limit;
|
|
@@ -833,8 +838,7 @@ function getSdkContextLimit(providerID, modelID, detectedContextLimit, options)
|
|
|
833
838
|
detectedLimitProvenance: options?.detectedLimitProvenance
|
|
834
839
|
})?.usableSoft;
|
|
835
840
|
}
|
|
836
|
-
|
|
837
|
-
const metadata = lookupMetadataWithTagFallback(apiCache, providerID, modelID);
|
|
841
|
+
const metadata = windowMetadata(providerID, modelID);
|
|
838
842
|
if (!metadata)
|
|
839
843
|
return;
|
|
840
844
|
const rawContext = metadata.contextLimit ?? metadata.limit;
|
|
@@ -22,7 +22,8 @@ async function ensureMemoryEmbeddings2(args) {
|
|
|
22
22
|
if (isEmbeddingHostBusy2())
|
|
23
23
|
return args.existingEmbeddings;
|
|
24
24
|
const snapshot = getProjectEmbeddingSnapshot2(args.projectIdentity);
|
|
25
|
-
|
|
25
|
+
const expected = args.expectedEmbedding;
|
|
26
|
+
if (!snapshot?.enabled || expected && (snapshot.modelId !== expected.modelId || expected.generation !== undefined && snapshot.generation !== expected.generation)) {
|
|
26
27
|
return args.existingEmbeddings;
|
|
27
28
|
}
|
|
28
29
|
const missing = args.memories.filter((memory) => !args.existingEmbeddings.has(memory.id)).sort((a, b) => a.id - b.id);
|
|
@@ -40,7 +41,8 @@ async function ensureMemoryEmbeddings2(args) {
|
|
|
40
41
|
text: memory.content,
|
|
41
42
|
contentSha256: contentSha2562(memory.content)
|
|
42
43
|
})), undefined, args.db, args.projectIdentity, { maxItemsPerCall: SEARCH_BACKFILL_REQUEST_SIZE });
|
|
43
|
-
|
|
44
|
+
const currentSnapshot = getProjectEmbeddingSnapshot2(args.projectIdentity);
|
|
45
|
+
if (!result || result.modelId !== snapshot.modelId || result.generation !== snapshot.generation || currentSnapshot?.generation !== snapshot.generation) {
|
|
44
46
|
return args.existingEmbeddings;
|
|
45
47
|
}
|
|
46
48
|
const staged = new Map;
|
|
@@ -56,10 +58,6 @@ async function ensureMemoryEmbeddings2(args) {
|
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
}).immediate();
|
|
59
|
-
const currentSnapshot = getProjectEmbeddingSnapshot2(args.projectIdentity);
|
|
60
|
-
if (!currentSnapshot || currentSnapshot.generation !== result.generation) {
|
|
61
|
-
return args.existingEmbeddings;
|
|
62
|
-
}
|
|
63
61
|
if (capped && (cursor !== undefined || result.vectors.size < missingMemories.length)) {
|
|
64
62
|
const nextCursor = start + missingMemories.length < missing.length ? missingMemories.at(-1)?.id : undefined;
|
|
65
63
|
writeSearchBackfillCursor2(args.projectIdentity, snapshot.generation, cursor, nextCursor);
|
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
} from "./index-yhzhdp3m.js";
|
|
70
70
|
import {
|
|
71
71
|
ensureMemoryEmbeddings2
|
|
72
|
-
} from "./index-
|
|
72
|
+
} from "./index-5tkveh4p.js";
|
|
73
73
|
import {
|
|
74
74
|
getMemorySelectColumns2,
|
|
75
75
|
isMemoryRow2,
|
|
@@ -595,19 +595,19 @@ function promoteSessionFactsDurable(db, sessionId, projectPath, facts) {
|
|
|
595
595
|
}
|
|
596
596
|
async function embedPromotedFacts(db, sessionId, projectPath, refs) {
|
|
597
597
|
for (const ref of refs) {
|
|
598
|
-
await embedAndStoreMemory(db, sessionId, projectPath, ref.memoryId
|
|
598
|
+
await embedAndStoreMemory(db, sessionId, projectPath, ref.memoryId);
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
|
-
async function embedAndStoreMemory(db, sessionId, projectPath, memoryId
|
|
601
|
+
async function embedAndStoreMemory(db, sessionId, projectPath, memoryId) {
|
|
602
602
|
try {
|
|
603
|
-
const
|
|
604
|
-
if (!
|
|
603
|
+
const memory = getMemoryById2(db, memoryId);
|
|
604
|
+
if (!memory?.normalizedHash) {
|
|
605
605
|
return;
|
|
606
606
|
}
|
|
607
|
-
const result = await embedTextForProject2(projectPath, content);
|
|
607
|
+
const result = await embedTextForProject2(projectPath, memory.content);
|
|
608
608
|
if (result) {
|
|
609
609
|
db.transaction(() => {
|
|
610
|
-
saveEmbeddingIfHashMatches(db, memoryId, result.vector, result.modelId,
|
|
610
|
+
saveEmbeddingIfHashMatches(db, memoryId, result.vector, result.modelId, memory.normalizedHash);
|
|
611
611
|
}).immediate();
|
|
612
612
|
}
|
|
613
613
|
} catch (error) {
|
|
@@ -2687,17 +2687,19 @@ async function getSemanticScores(args) {
|
|
|
2687
2687
|
if (!args.queryEmbedding || args.memories.length === 0 || !args.queryModelId || args.queryModelId === "off") {
|
|
2688
2688
|
return semanticScores;
|
|
2689
2689
|
}
|
|
2690
|
+
const expectedEmbedding = { modelId: args.queryModelId, generation: args.queryGeneration };
|
|
2690
2691
|
if (!args.workspace?.isWorkspaced) {
|
|
2691
2692
|
const cachedEmbeddings = getProjectEmbeddings2(args.db, args.projectPath, args.queryModelId);
|
|
2692
2693
|
const embeddings = args.backfillMemoryEmbeddings === false ? cachedEmbeddings : await ensureMemoryEmbeddings2({
|
|
2693
2694
|
db: args.db,
|
|
2694
2695
|
projectIdentity: args.projectPath,
|
|
2695
2696
|
memories: args.memories,
|
|
2696
|
-
existingEmbeddings: cachedEmbeddings
|
|
2697
|
+
existingEmbeddings: cachedEmbeddings,
|
|
2698
|
+
expectedEmbedding
|
|
2697
2699
|
});
|
|
2698
2700
|
for (const memory of args.memories) {
|
|
2699
2701
|
const memoryEmbedding = embeddings.get(memory.id);
|
|
2700
|
-
if (!memoryEmbedding) {
|
|
2702
|
+
if (!memoryEmbedding || memoryEmbedding.modelId !== args.queryModelId) {
|
|
2701
2703
|
continue;
|
|
2702
2704
|
}
|
|
2703
2705
|
semanticScores.set(memory.id, normalizeCosineScore(cosineSimilarity(args.queryEmbedding, memoryEmbedding.embedding)));
|
|
@@ -2721,7 +2723,8 @@ async function getSemanticScores(args) {
|
|
|
2721
2723
|
db: args.db,
|
|
2722
2724
|
projectIdentity: args.projectPath,
|
|
2723
2725
|
memories: ownMemories,
|
|
2724
|
-
existingEmbeddings: ownEmbeddings
|
|
2726
|
+
existingEmbeddings: ownEmbeddings,
|
|
2727
|
+
expectedEmbedding
|
|
2725
2728
|
});
|
|
2726
2729
|
}
|
|
2727
2730
|
for (const identity of workspace.identities) {
|
|
@@ -2849,6 +2852,7 @@ async function searchMemories(args) {
|
|
|
2849
2852
|
backfillMemoryEmbeddings: args.backfillMemoryEmbeddings,
|
|
2850
2853
|
queryEmbedding: args.queryEmbedding,
|
|
2851
2854
|
queryModelId: args.queryModelId,
|
|
2855
|
+
queryGeneration: args.queryGeneration,
|
|
2852
2856
|
workspace: args.workspace
|
|
2853
2857
|
});
|
|
2854
2858
|
const sourceNameByMemoryId = sourceNamesForSearchMemories({
|
|
@@ -3751,6 +3755,7 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3751
3755
|
memoryEnabled: true,
|
|
3752
3756
|
queryEmbedding,
|
|
3753
3757
|
queryModelId: embeddingModelId && embeddingModelId !== "off" ? embeddingModelId : null,
|
|
3758
|
+
queryGeneration: queryContract?.generation ?? embeddingSnapshot?.generation,
|
|
3754
3759
|
workspace,
|
|
3755
3760
|
visibleMemoryIds: options.visibleMemoryIds,
|
|
3756
3761
|
backfillMemoryEmbeddings: options.backfillMemoryEmbeddings,
|
package/dist/index.js
CHANGED
|
@@ -166,7 +166,7 @@ import {
|
|
|
166
166
|
registerTodoStateLifecycle,
|
|
167
167
|
syncCtxMemoryToolEnabled,
|
|
168
168
|
registerMagicContextTools
|
|
169
|
-
} from "./index-
|
|
169
|
+
} from "./index-5009ew3c.js";
|
|
170
170
|
import"./index-4knyh1kt.js";
|
|
171
171
|
import {
|
|
172
172
|
canonicalModelIdentity,
|
|
@@ -832,8 +832,8 @@ import {
|
|
|
832
832
|
scheduleClearAndReindex,
|
|
833
833
|
clearSessionTracking,
|
|
834
834
|
createAutoSearchDiagnostics
|
|
835
|
-
} from "./index-
|
|
836
|
-
import"./index-
|
|
835
|
+
} from "./index-pz85rpzf.js";
|
|
836
|
+
import"./index-5tkveh4p.js";
|
|
837
837
|
import"./index-3s39a1md.js";
|
|
838
838
|
import {
|
|
839
839
|
DREAMER_PRIMER_INVESTIGATOR_ALLOWED_TOOLS,
|
|
@@ -3619,7 +3619,7 @@ function startHostStallProfilerSwitch() {
|
|
|
3619
3619
|
// package.json
|
|
3620
3620
|
var package_default = {
|
|
3621
3621
|
name: "@cortexkit/pi-magic-context",
|
|
3622
|
-
version: "0.49.
|
|
3622
|
+
version: "0.49.81",
|
|
3623
3623
|
type: "module",
|
|
3624
3624
|
description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
3625
3625
|
main: "dist/index.js",
|
|
@@ -19374,11 +19374,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
19374
19374
|
if (task === "maintain-docs" && hasCurrentDocsProposal(docsDir)) {
|
|
19375
19375
|
const reason = "pending proposal matches current docs";
|
|
19376
19376
|
helpers.recordRun("completed", null, { progress: reason });
|
|
19377
|
-
return {
|
|
19378
|
-
status: "completed",
|
|
19379
|
-
detail: reason,
|
|
19380
|
-
...changes ? { schedulePatch: { taskStateJson: JSON.stringify({ head: changes.head }) } } : {}
|
|
19381
|
-
};
|
|
19377
|
+
return { status: "completed", detail: reason };
|
|
19382
19378
|
}
|
|
19383
19379
|
const curateChunks = curateMemories ? chunkCurateMemories(curateMemories, Math.max(4000, Math.floor(resolveRetrospectiveUsableInputTokens(config, deps) * 2))) : [];
|
|
19384
19380
|
const batches = task === "curate" ? curateChunks : [{ memories: [], crossChunkCandidates: [] }];
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
resolveMemoriesByIdsForSearch2,
|
|
6
6
|
unifiedSearch2,
|
|
7
7
|
formatSearchResults2
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-pz85rpzf.js";
|
|
9
9
|
import"./index-k7a8x7ba.js";
|
|
10
10
|
import"./index-0t9xfj3x.js";
|
|
11
11
|
import"./index-8d2z6503.js";
|
|
12
|
-
import"./index-
|
|
12
|
+
import"./index-5tkveh4p.js";
|
|
13
13
|
import"./index-29nw7n1r.js";
|
|
14
14
|
import"./index-0bmsfzqf.js";
|
|
15
15
|
import"./index-9p40dgkm.js";
|
package/dist/subagent-entry.js
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
resolvePiHarnessKind,
|
|
35
35
|
reportSubagentStartupError,
|
|
36
36
|
registerMagicContextTools
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-5009ew3c.js";
|
|
38
38
|
import"./index-vcegxfwg.js";
|
|
39
39
|
import"./index-5rcjs14a.js";
|
|
40
40
|
import"./index-cxczethe.js";
|
|
@@ -44,7 +44,7 @@ import"./index-hgd00nas.js";
|
|
|
44
44
|
import"./index-9p40dgkm.js";
|
|
45
45
|
import"./index-79xfn84y.js";
|
|
46
46
|
import"./index-yhzhdp3m.js";
|
|
47
|
-
import"./index-
|
|
47
|
+
import"./index-pz85rpzf.js";
|
|
48
48
|
import"./index-6crdakkm.js";
|
|
49
49
|
import"./index-0t9xfj3x.js";
|
|
50
50
|
import"./index-nh4srq1p.js";
|
|
@@ -54,7 +54,7 @@ import"./index-k7a8x7ba.js";
|
|
|
54
54
|
import"./index-8d2z6503.js";
|
|
55
55
|
import"./index-hnvq96j6.js";
|
|
56
56
|
import"./index-fvfq9gva.js";
|
|
57
|
-
import"./index-
|
|
57
|
+
import"./index-5tkveh4p.js";
|
|
58
58
|
import"./index-29nw7n1r.js";
|
|
59
59
|
import"./index-3s39a1md.js";
|
|
60
60
|
import"./index-1ts77n1b.js";
|
package/package.json
CHANGED