@cortexkit/pi-magic-context 0.49.61 → 0.49.62
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/index.js +26 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3601,7 +3601,7 @@ function startHostStallProfilerSwitch() {
|
|
|
3601
3601
|
// package.json
|
|
3602
3602
|
var package_default = {
|
|
3603
3603
|
name: "@cortexkit/pi-magic-context",
|
|
3604
|
-
version: "0.49.
|
|
3604
|
+
version: "0.49.62",
|
|
3605
3605
|
type: "module",
|
|
3606
3606
|
description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
3607
3607
|
main: "dist/index.js",
|
|
@@ -29134,10 +29134,13 @@ function safeJsonStringify(value) {
|
|
|
29134
29134
|
function isRecord2(value) {
|
|
29135
29135
|
return typeof value === "object" && value !== null;
|
|
29136
29136
|
}
|
|
29137
|
+
function isUntaggedAssistantText(role, text, preserveTagOnlyAssistantText) {
|
|
29138
|
+
return role === "assistant" && (stripWellFormedLeadingTagPrefix(text).trim().length === 0 || preserveTagOnlyAssistantText === true && text.includes("§") && stripPersistedAssistantText(text).length === 0);
|
|
29139
|
+
}
|
|
29137
29140
|
function tagTextPart(args) {
|
|
29138
29141
|
const identityStart = args.timing ? performance.now() : 0;
|
|
29139
29142
|
const text = args.part.getText() ?? "";
|
|
29140
|
-
if (args.message.info.role
|
|
29143
|
+
if (isUntaggedAssistantText(args.message.info.role, text, args.preserveTagOnlyAssistantText)) {
|
|
29141
29144
|
if (args.timing)
|
|
29142
29145
|
args.timing.identity += performance.now() - identityStart;
|
|
29143
29146
|
return;
|
|
@@ -48079,13 +48082,27 @@ var piTagTextTokenCacheBySession = new Map;
|
|
|
48079
48082
|
var piTagToolTokenCacheBySession = new Map;
|
|
48080
48083
|
var piTextIdentitySourceCacheBySession = new Map;
|
|
48081
48084
|
var piFallbackIndexesBySession = new Map;
|
|
48085
|
+
var PI_PRESERVE_TAG_ONLY_ASSISTANT_TEXT = true;
|
|
48082
48086
|
function buildPiTextIdentityPlan(db, sessionId, tagger, transcript, reuseCandidates = new Set) {
|
|
48083
48087
|
const currentSourcesByMessageId = new Map;
|
|
48088
|
+
const untaggedOrdinalsByMessageId = new Map;
|
|
48084
48089
|
for (const message of transcript.messages) {
|
|
48085
48090
|
const messageId = message.info.id;
|
|
48086
48091
|
if (messageId === undefined)
|
|
48087
48092
|
continue;
|
|
48088
|
-
|
|
48093
|
+
const sources = [];
|
|
48094
|
+
const untagged = new Set;
|
|
48095
|
+
for (const part of message.parts) {
|
|
48096
|
+
if (part.kind !== "text")
|
|
48097
|
+
continue;
|
|
48098
|
+
const text = part.getText() ?? "";
|
|
48099
|
+
if (isUntaggedAssistantText(message.info.role, text, PI_PRESERVE_TAG_ONLY_ASSISTANT_TEXT))
|
|
48100
|
+
untagged.add(sources.length);
|
|
48101
|
+
sources.push(withoutPiLeadingTemporalMarker(stripTagPrefix(text)));
|
|
48102
|
+
}
|
|
48103
|
+
currentSourcesByMessageId.set(messageId, sources);
|
|
48104
|
+
if (untagged.size > 0)
|
|
48105
|
+
untaggedOrdinalsByMessageId.set(messageId, untagged);
|
|
48089
48106
|
}
|
|
48090
48107
|
const legacyRowsByMessageId = new Map;
|
|
48091
48108
|
const versionedMessageIds = new Set;
|
|
@@ -48133,11 +48150,12 @@ function buildPiTextIdentityPlan(db, sessionId, tagger, transcript, reuseCandida
|
|
|
48133
48150
|
if (legacyRows.length === 0)
|
|
48134
48151
|
continue;
|
|
48135
48152
|
legacyRows.sort((left, right) => left.ordinal - right.ordinal);
|
|
48136
|
-
const
|
|
48137
|
-
|
|
48138
|
-
|
|
48153
|
+
const untagged = untaggedOrdinalsByMessageId.get(messageId);
|
|
48154
|
+
const rowOrdinals = new Set(legacyRows.map((row) => row.ordinal));
|
|
48155
|
+
const vectorAligned = rowOrdinals.size === legacyRows.length && legacyRows.every((row) => row.ordinal < currentSources.length) && currentSources.every((_, ordinal) => rowOrdinals.has(ordinal) || untagged?.has(ordinal) === true);
|
|
48156
|
+
const vectorMatches = vectorAligned && legacyRows.every((row) => {
|
|
48139
48157
|
const stored = withoutPiLeadingTemporalMarker(sourceCache.get(row.tagId) ?? "");
|
|
48140
|
-
const current = currentSources[
|
|
48158
|
+
const current = currentSources[row.ordinal] ?? "";
|
|
48141
48159
|
if (stored === current)
|
|
48142
48160
|
return true;
|
|
48143
48161
|
const strippedCurrent = stripSystemInjection(current);
|
|
@@ -52678,7 +52696,7 @@ async function runPipeline(args) {
|
|
|
52678
52696
|
args.assertCurrentPass?.();
|
|
52679
52697
|
return tagTranscript(args.sessionId, { ...transcript, messages: taggingView }, args.tagger, args.db, {
|
|
52680
52698
|
skipPrefixInjection: !ctxReduceCallable,
|
|
52681
|
-
preserveTagOnlyAssistantText:
|
|
52699
|
+
preserveTagOnlyAssistantText: PI_PRESERVE_TAG_ONLY_ASSISTANT_TEXT,
|
|
52682
52700
|
entryFingerprintByMessageId,
|
|
52683
52701
|
reuseMessageIds: textIdentityPlan.reusableMessageIds,
|
|
52684
52702
|
reuseTextMessageIds: textIdentityPlan.reusableTextMessageIds,
|
package/package.json
CHANGED