@cortexkit/pi-magic-context 0.32.2 → 0.32.3
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 +131 -43
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -159549,26 +159549,32 @@ init_logger();
|
|
|
159549
159549
|
// ../plugin/src/features/magic-context/compaction-marker.ts
|
|
159550
159550
|
init_data_path();
|
|
159551
159551
|
init_logger();
|
|
159552
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
159552
159553
|
import { existsSync as existsSync10 } from "node:fs";
|
|
159553
159554
|
import { join as join9 } from "node:path";
|
|
159554
159555
|
var BASE62_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
159555
|
-
|
|
159556
|
-
|
|
159557
|
-
|
|
159558
|
-
|
|
159556
|
+
var ID_PREFIX_HEX_LENGTH = 12;
|
|
159557
|
+
var ID_SUFFIX_LENGTH = 14;
|
|
159558
|
+
var ID_PREFIX_MASK = (1n << BigInt(ID_PREFIX_HEX_LENGTH * 4)) - 1n;
|
|
159559
|
+
function deterministicBase62(seed, length) {
|
|
159560
|
+
let value = BigInt(`0x${createHash7("sha256").update(seed).digest("hex")}`);
|
|
159561
|
+
const chars = Array(length);
|
|
159562
|
+
for (let index = length - 1;index >= 0; index -= 1) {
|
|
159563
|
+
chars[index] = BASE62_CHARS[Number(value % 62n)];
|
|
159564
|
+
value /= 62n;
|
|
159559
159565
|
}
|
|
159560
159566
|
return chars.join("");
|
|
159561
159567
|
}
|
|
159562
|
-
function generateId(prefix, timestampMs, counter
|
|
159563
|
-
const encoded = BigInt(timestampMs) * 0x1000n + counter;
|
|
159564
|
-
const hex = encoded.toString(16).padStart(
|
|
159565
|
-
return `${prefix}_${hex}${
|
|
159568
|
+
function generateId(prefix, timestampMs, counter, identity) {
|
|
159569
|
+
const encoded = BigInt(Math.max(0, Math.floor(timestampMs))) * 0x1000n + counter & ID_PREFIX_MASK;
|
|
159570
|
+
const hex = encoded.toString(16).padStart(ID_PREFIX_HEX_LENGTH, "0");
|
|
159571
|
+
return `${prefix}_${hex}${deterministicBase62(`${prefix}\x00${identity}`, ID_SUFFIX_LENGTH)}`;
|
|
159566
159572
|
}
|
|
159567
|
-
function generateMessageId(timestampMs, counter = 0n) {
|
|
159568
|
-
return generateId("msg", timestampMs, counter);
|
|
159573
|
+
function generateMessageId(timestampMs, counter = 0n, identity = "") {
|
|
159574
|
+
return generateId("msg", timestampMs, counter, identity);
|
|
159569
159575
|
}
|
|
159570
|
-
function generatePartId(timestampMs, counter = 0n) {
|
|
159571
|
-
return generateId("prt", timestampMs, counter);
|
|
159576
|
+
function generatePartId(timestampMs, counter = 0n, identity = "") {
|
|
159577
|
+
return generateId("prt", timestampMs, counter, identity);
|
|
159572
159578
|
}
|
|
159573
159579
|
function getOpenCodeDbPath2() {
|
|
159574
159580
|
return join9(getDataDir(), "opencode", "opencode.db");
|
|
@@ -159673,6 +159679,38 @@ function compareOpenCodeMessagesByCanonicalOrder(sessionId, leftMessageId, right
|
|
|
159673
159679
|
return 1;
|
|
159674
159680
|
return 0;
|
|
159675
159681
|
}
|
|
159682
|
+
function removeLegacyMarkerLineageRows(db, args) {
|
|
159683
|
+
const legacySummaries = db.prepare(`SELECT m.id
|
|
159684
|
+
FROM message m
|
|
159685
|
+
WHERE m.session_id = ?
|
|
159686
|
+
AND m.id <> ?
|
|
159687
|
+
AND COALESCE(json_extract(m.data, '$.summary'), 0) = 1
|
|
159688
|
+
AND COALESCE(json_extract(m.data, '$.finish'), '') = 'stop'
|
|
159689
|
+
AND COALESCE(json_extract(m.data, '$.parentID'), '') = ?
|
|
159690
|
+
AND EXISTS (
|
|
159691
|
+
SELECT 1
|
|
159692
|
+
FROM part p
|
|
159693
|
+
WHERE p.session_id = m.session_id
|
|
159694
|
+
AND p.message_id = m.id
|
|
159695
|
+
AND COALESCE(json_extract(p.data, '$.type'), '') = 'text'
|
|
159696
|
+
AND COALESCE(json_extract(p.data, '$.text'), '') = ?
|
|
159697
|
+
)`).all(args.sessionId, args.summaryMessageId, args.boundaryMessageId, args.summaryText);
|
|
159698
|
+
const legacySummaryIds = legacySummaries.flatMap((row) => typeof row.id === "string" ? [row.id] : []);
|
|
159699
|
+
if (legacySummaryIds.length === 0)
|
|
159700
|
+
return;
|
|
159701
|
+
const deleteSummaryParts = db.prepare("DELETE FROM part WHERE session_id = ? AND message_id = ?");
|
|
159702
|
+
const deleteSummary = db.prepare("DELETE FROM message WHERE session_id = ? AND id = ?");
|
|
159703
|
+
for (const summaryMessageId of legacySummaryIds) {
|
|
159704
|
+
deleteSummaryParts.run(args.sessionId, summaryMessageId);
|
|
159705
|
+
deleteSummary.run(args.sessionId, summaryMessageId);
|
|
159706
|
+
}
|
|
159707
|
+
db.prepare(`DELETE FROM part
|
|
159708
|
+
WHERE session_id = ?
|
|
159709
|
+
AND message_id = ?
|
|
159710
|
+
AND id <> ?
|
|
159711
|
+
AND COALESCE(json_extract(data, '$.type'), '') = 'compaction'
|
|
159712
|
+
AND COALESCE(json_extract(data, '$.auto'), 0) = 1`).run(args.sessionId, args.boundaryMessageId, args.compactionPartId);
|
|
159713
|
+
}
|
|
159676
159714
|
function injectCompactionMarker(args) {
|
|
159677
159715
|
const db = getWritableOpenCodeDb();
|
|
159678
159716
|
if (!isOpenCodeSchemaCompatible(db, getOpenCodeDbPath2())) {
|
|
@@ -159684,9 +159722,10 @@ function injectCompactionMarker(args) {
|
|
|
159684
159722
|
return null;
|
|
159685
159723
|
}
|
|
159686
159724
|
const boundaryTime = boundary.timeCreated;
|
|
159687
|
-
const
|
|
159688
|
-
const
|
|
159689
|
-
const
|
|
159725
|
+
const markerIdentity = `${args.sessionId}\x00${args.endMessageId}`;
|
|
159726
|
+
const summaryMsgId = generateMessageId(boundaryTime + 1, 1n, `${markerIdentity}\x00summary-message`);
|
|
159727
|
+
const compactionPartId = generatePartId(boundaryTime, 1n, `${markerIdentity}\x00compaction-part`);
|
|
159728
|
+
const summaryPartId = generatePartId(boundaryTime + 1, 2n, `${markerIdentity}\x00summary-part`);
|
|
159690
159729
|
const summaryMsgData = JSON.stringify({
|
|
159691
159730
|
role: "assistant",
|
|
159692
159731
|
parentID: boundary.id,
|
|
@@ -159703,9 +159742,36 @@ function injectCompactionMarker(args) {
|
|
|
159703
159742
|
});
|
|
159704
159743
|
try {
|
|
159705
159744
|
db.transaction(() => {
|
|
159706
|
-
db
|
|
159707
|
-
|
|
159708
|
-
|
|
159745
|
+
removeLegacyMarkerLineageRows(db, {
|
|
159746
|
+
sessionId: args.sessionId,
|
|
159747
|
+
boundaryMessageId: boundary.id,
|
|
159748
|
+
summaryText: args.summaryText,
|
|
159749
|
+
summaryMessageId: summaryMsgId,
|
|
159750
|
+
compactionPartId
|
|
159751
|
+
});
|
|
159752
|
+
db.prepare(`INSERT INTO part (id, message_id, session_id, time_created, time_updated, data)
|
|
159753
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
159754
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
159755
|
+
message_id = excluded.message_id,
|
|
159756
|
+
session_id = excluded.session_id,
|
|
159757
|
+
time_created = excluded.time_created,
|
|
159758
|
+
time_updated = excluded.time_updated,
|
|
159759
|
+
data = excluded.data`).run(compactionPartId, boundary.id, args.sessionId, boundaryTime, boundaryTime, '{"type":"compaction","auto":true}');
|
|
159760
|
+
db.prepare(`INSERT INTO message (id, session_id, time_created, time_updated, data)
|
|
159761
|
+
VALUES (?, ?, ?, ?, ?)
|
|
159762
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
159763
|
+
session_id = excluded.session_id,
|
|
159764
|
+
time_created = excluded.time_created,
|
|
159765
|
+
time_updated = excluded.time_updated,
|
|
159766
|
+
data = excluded.data`).run(summaryMsgId, args.sessionId, boundaryTime + 1, boundaryTime + 1, summaryMsgData);
|
|
159767
|
+
db.prepare(`INSERT INTO part (id, message_id, session_id, time_created, time_updated, data)
|
|
159768
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
159769
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
159770
|
+
message_id = excluded.message_id,
|
|
159771
|
+
session_id = excluded.session_id,
|
|
159772
|
+
time_created = excluded.time_created,
|
|
159773
|
+
time_updated = excluded.time_updated,
|
|
159774
|
+
data = excluded.data`).run(summaryPartId, summaryMsgId, args.sessionId, boundaryTime + 1, boundaryTime + 1, JSON.stringify({ type: "text", text: args.summaryText }));
|
|
159709
159775
|
})();
|
|
159710
159776
|
log(`[magic-context] compaction-marker: injected boundary at user msg ${boundary.id} (ordinal ~${args.endOrdinal}), summary msg ${summaryMsgId}`);
|
|
159711
159777
|
return {
|
|
@@ -159752,7 +159818,7 @@ function openOpenCodeDb() {
|
|
|
159752
159818
|
}
|
|
159753
159819
|
|
|
159754
159820
|
// ../plugin/src/features/magic-context/dreamer/task-executor.ts
|
|
159755
|
-
import { createHash as
|
|
159821
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
159756
159822
|
import { existsSync as existsSync15 } from "node:fs";
|
|
159757
159823
|
|
|
159758
159824
|
// ../plugin/src/agents/dreamer.ts
|
|
@@ -174844,7 +174910,7 @@ var MagicContextConfigSchema = exports_external.object({
|
|
|
174844
174910
|
init_logger();
|
|
174845
174911
|
|
|
174846
174912
|
// ../plugin/src/features/magic-context/compartment-chunk-embedding.ts
|
|
174847
|
-
import { createHash as
|
|
174913
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
174848
174914
|
init_logger();
|
|
174849
174915
|
|
|
174850
174916
|
// ../plugin/src/features/magic-context/recursive-text-splitter.ts
|
|
@@ -175056,7 +175122,7 @@ function parseCanonicalLineRange(line) {
|
|
|
175056
175122
|
return { start, end };
|
|
175057
175123
|
}
|
|
175058
175124
|
function hashChunkText(text) {
|
|
175059
|
-
return
|
|
175125
|
+
return createHash8("sha256").update(text).digest("hex");
|
|
175060
175126
|
}
|
|
175061
175127
|
function vectorBlob2(vector) {
|
|
175062
175128
|
return new Uint8Array(vector.buffer, vector.byteOffset, vector.byteLength);
|
|
@@ -175449,7 +175515,7 @@ function cosineSimilarity(a, b) {
|
|
|
175449
175515
|
}
|
|
175450
175516
|
|
|
175451
175517
|
// ../plugin/src/features/magic-context/memory/embedding-synapse.ts
|
|
175452
|
-
import { createHash as
|
|
175518
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
175453
175519
|
|
|
175454
175520
|
// ../../node_modules/.bun/@cortexkit+subc-client@0.4.1/node_modules/@cortexkit/subc-client/dist/client.js
|
|
175455
175521
|
import { promises as fs4 } from "node:fs";
|
|
@@ -177663,7 +177729,7 @@ function wait(ms) {
|
|
|
177663
177729
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
177664
177730
|
}
|
|
177665
177731
|
function sha256(value) {
|
|
177666
|
-
return
|
|
177732
|
+
return createHash9("sha256").update(value).digest("hex");
|
|
177667
177733
|
}
|
|
177668
177734
|
function stableJson(value) {
|
|
177669
177735
|
if (Array.isArray(value))
|
|
@@ -178069,13 +178135,13 @@ class SynapseEmbeddingProvider {
|
|
|
178069
178135
|
}
|
|
178070
178136
|
|
|
178071
178137
|
// ../plugin/src/features/magic-context/memory/normalize-hash.ts
|
|
178072
|
-
import { createHash as
|
|
178138
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
178073
178139
|
function normalizeMemoryContent(content) {
|
|
178074
178140
|
return content.toLowerCase().replace(/\s+/g, " ").trim();
|
|
178075
178141
|
}
|
|
178076
178142
|
function computeNormalizedHash(content) {
|
|
178077
178143
|
const normalized = normalizeMemoryContent(content);
|
|
178078
|
-
return
|
|
178144
|
+
return createHash10("md5").update(normalized).digest("hex");
|
|
178079
178145
|
}
|
|
178080
178146
|
|
|
178081
178147
|
// ../plugin/src/features/magic-context/memory/embedding-identity.ts
|
|
@@ -178884,7 +178950,7 @@ function getMemoryEmbedCoverage(db, projectPath, modelId) {
|
|
|
178884
178950
|
}
|
|
178885
178951
|
|
|
178886
178952
|
// ../plugin/src/features/magic-context/project-embedding-registry.ts
|
|
178887
|
-
import { createHash as
|
|
178953
|
+
import { createHash as createHash11, randomUUID as randomUUID2 } from "node:crypto";
|
|
178888
178954
|
init_logger();
|
|
178889
178955
|
|
|
178890
178956
|
// ../plugin/src/features/magic-context/git-commits/storage-git-commit-embeddings.ts
|
|
@@ -179416,10 +179482,10 @@ function stableStringify2(value) {
|
|
|
179416
179482
|
return JSON.stringify(value);
|
|
179417
179483
|
}
|
|
179418
179484
|
function sha256Prefix(value, length = 16) {
|
|
179419
|
-
return
|
|
179485
|
+
return createHash11("sha256").update(value).digest("hex").slice(0, length);
|
|
179420
179486
|
}
|
|
179421
179487
|
function contentSha256(value) {
|
|
179422
|
-
return
|
|
179488
|
+
return createHash11("sha256").update(value).digest("hex");
|
|
179423
179489
|
}
|
|
179424
179490
|
function getRuntimeFingerprint(config2) {
|
|
179425
179491
|
if (config2.provider === "off") {
|
|
@@ -183386,7 +183452,7 @@ function throwIfAborted2(signal) {
|
|
|
183386
183452
|
}
|
|
183387
183453
|
|
|
183388
183454
|
// ../plugin/src/features/magic-context/smart-notes/compiler.ts
|
|
183389
|
-
import { createHash as
|
|
183455
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
183390
183456
|
init_logger();
|
|
183391
183457
|
|
|
183392
183458
|
// ../plugin/src/features/magic-context/smart-notes/compiler-prompt.ts
|
|
@@ -183820,7 +183886,7 @@ function manifestAdvisoryWarnings(code, manifest) {
|
|
|
183820
183886
|
return warnings;
|
|
183821
183887
|
}
|
|
183822
183888
|
function hashCheck(surfaceCondition, compiledCheck, manifest, checkCron) {
|
|
183823
|
-
return
|
|
183889
|
+
return createHash12("sha256").update(surfaceCondition ?? "").update("\x00").update(compiledCheck).update("\x00").update(JSON.stringify(manifest)).update("\x00").update(checkCron).digest("hex");
|
|
183824
183890
|
}
|
|
183825
183891
|
function extractJsonObject(output) {
|
|
183826
183892
|
const fenced = output.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
@@ -186632,7 +186698,7 @@ function parseFrictionGateVerdict(verdict) {
|
|
|
186632
186698
|
}
|
|
186633
186699
|
function computeRetrospectiveWindowKey(flagged) {
|
|
186634
186700
|
const anchors = flagged.map((message) => `${message.sessionId}:${message.ts}`).sort().join("|");
|
|
186635
|
-
return
|
|
186701
|
+
return createHash13("sha256").update(anchors).digest("hex").slice(0, 32);
|
|
186636
186702
|
}
|
|
186637
186703
|
function renderFrictionWindow(messages, flaggedOrdinals, radius = 2) {
|
|
186638
186704
|
const flagged = new Set(flaggedOrdinals);
|
|
@@ -187959,7 +188025,7 @@ async function sweepGitCommits(args) {
|
|
|
187959
188025
|
import { statSync as statSync7 } from "node:fs";
|
|
187960
188026
|
|
|
187961
188027
|
// ../plugin/src/plugin/embedding-bootstrap-helpers.ts
|
|
187962
|
-
import { createHash as
|
|
188028
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
187963
188029
|
init_logger();
|
|
187964
188030
|
var EMBEDDING_AFFECTING_KEYS = new Set([
|
|
187965
188031
|
"embedding.api_key",
|
|
@@ -188006,7 +188072,7 @@ var EMBEDDING_WARNING_TERMS = [
|
|
|
188006
188072
|
];
|
|
188007
188073
|
var loggedFailureSignatures = new Map;
|
|
188008
188074
|
function sha256Prefix2(value, length = 16) {
|
|
188009
|
-
return
|
|
188075
|
+
return createHash14("sha256").update(value).digest("hex").slice(0, length);
|
|
188010
188076
|
}
|
|
188011
188077
|
function warningLooksEmbeddingRelated(message) {
|
|
188012
188078
|
const lower = message.toLowerCase();
|
|
@@ -194190,7 +194256,7 @@ function containsProbeVerbatim(text, probes) {
|
|
|
194190
194256
|
}
|
|
194191
194257
|
|
|
194192
194258
|
// ../plugin/src/features/magic-context/search-measurement.ts
|
|
194193
|
-
import { createHash as
|
|
194259
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
194194
194260
|
function resultId(result) {
|
|
194195
194261
|
switch (result.source) {
|
|
194196
194262
|
case "memory":
|
|
@@ -194273,7 +194339,7 @@ async function recordShadowMeasurement(args) {
|
|
|
194273
194339
|
});
|
|
194274
194340
|
}
|
|
194275
194341
|
function sha2562(value) {
|
|
194276
|
-
return
|
|
194342
|
+
return createHash15("sha256").update(value).digest("hex");
|
|
194277
194343
|
}
|
|
194278
194344
|
|
|
194279
194345
|
// ../plugin/src/features/magic-context/search.ts
|
|
@@ -201761,7 +201827,7 @@ function stripPiProcessedImages(args) {
|
|
|
201761
201827
|
}
|
|
201762
201828
|
|
|
201763
201829
|
// src/system-prompt.ts
|
|
201764
|
-
import { createHash as
|
|
201830
|
+
import { createHash as createHash16 } from "node:crypto";
|
|
201765
201831
|
|
|
201766
201832
|
// ../plugin/src/agents/magic-context-prompt.ts
|
|
201767
201833
|
var LONG_TERM_PARTNER_FRAME = `### You are the user's long-term partner on this project — not a one-off hire
|
|
@@ -201914,7 +201980,7 @@ function processSystemPromptForCache(args) {
|
|
|
201914
201980
|
sessionLog(sessionId, `system prompt date frozen: real=${liveDate}, using=${stickyDate} (cache-stable pass)`);
|
|
201915
201981
|
}
|
|
201916
201982
|
}
|
|
201917
|
-
const currentHash =
|
|
201983
|
+
const currentHash = createHash16("md5").update(frozenPrompt).digest("hex");
|
|
201918
201984
|
const hashChanged = !isFirstHash && currentHash !== previousHash;
|
|
201919
201985
|
if (hashChanged) {
|
|
201920
201986
|
sessionLog(sessionId, `system prompt hash changed: ${previousHash} → ${currentHash} (len=${frozenPrompt.length})`);
|
|
@@ -205062,6 +205128,19 @@ init_logger();
|
|
|
205062
205128
|
init_data_path();
|
|
205063
205129
|
init_logger();
|
|
205064
205130
|
var MARKER_SUMMARY_TEXT = "[Compacted by magic-context — session history is managed by the plugin]";
|
|
205131
|
+
function dropMarkerSummaryTag(db, sessionId, summaryMessageId) {
|
|
205132
|
+
const tagNumber = getTagNumberByMessageId(db, sessionId, `${summaryMessageId}:p0`);
|
|
205133
|
+
if (tagNumber !== null)
|
|
205134
|
+
updateTagStatus(db, sessionId, tagNumber, "dropped");
|
|
205135
|
+
}
|
|
205136
|
+
function persistMarkerStateAndDropReplacedTag(db, sessionId, state, replacedSummaryMessageId) {
|
|
205137
|
+
db.transaction(() => {
|
|
205138
|
+
setPersistedCompactionMarkerState(db, sessionId, state);
|
|
205139
|
+
if (replacedSummaryMessageId !== null) {
|
|
205140
|
+
dropMarkerSummaryTag(db, sessionId, replacedSummaryMessageId);
|
|
205141
|
+
}
|
|
205142
|
+
})();
|
|
205143
|
+
}
|
|
205065
205144
|
function getCompartmentEndMessageIdForOrdinal(db, sessionId, endOrdinal) {
|
|
205066
205145
|
const row = db.prepare(`SELECT end_message_id
|
|
205067
205146
|
FROM compartments
|
|
@@ -205102,6 +205181,7 @@ function updateCompactionMarkerAfterPublication(db, sessionId, lastCompartmentEn
|
|
|
205102
205181
|
return false;
|
|
205103
205182
|
}
|
|
205104
205183
|
const existing = getPersistedCompactionMarkerState(db, sessionId);
|
|
205184
|
+
const removedSummaryMessageId = existing?.summaryMessageId ?? null;
|
|
205105
205185
|
if (existing) {
|
|
205106
205186
|
if (existingMarkerAlreadyCoversTarget(sessionId, existing, lastCompartmentEnd, targetEndMessageId)) {
|
|
205107
205187
|
return true;
|
|
@@ -205118,7 +205198,7 @@ function updateCompactionMarkerAfterPublication(db, sessionId, lastCompartmentEn
|
|
|
205118
205198
|
sessionLog(sessionId, `compaction-marker: failed to remove old boundary at ordinal ${existing.boundaryOrdinal}; preserving persisted state for retry (not injecting new marker this pass)`);
|
|
205119
205199
|
return false;
|
|
205120
205200
|
}
|
|
205121
|
-
|
|
205201
|
+
persistMarkerStateAndDropReplacedTag(db, sessionId, null, removedSummaryMessageId);
|
|
205122
205202
|
sessionLog(sessionId, `compaction-marker: removed old boundary at ordinal ${existing.boundaryOrdinal}, moving to ${lastCompartmentEnd}`);
|
|
205123
205203
|
}
|
|
205124
205204
|
const result = injectCompactionMarker({
|
|
@@ -205130,11 +205210,11 @@ function updateCompactionMarkerAfterPublication(db, sessionId, lastCompartmentEn
|
|
|
205130
205210
|
resolvedBoundary: boundary
|
|
205131
205211
|
});
|
|
205132
205212
|
if (result) {
|
|
205133
|
-
|
|
205213
|
+
persistMarkerStateAndDropReplacedTag(db, sessionId, {
|
|
205134
205214
|
...result,
|
|
205135
205215
|
boundaryOrdinal: lastCompartmentEnd,
|
|
205136
205216
|
targetEndMessageId
|
|
205137
|
-
});
|
|
205217
|
+
}, removedSummaryMessageId);
|
|
205138
205218
|
sessionLog(sessionId, `compaction-marker: injected at ordinal ${lastCompartmentEnd}, boundary user msg ${result.boundaryMessageId}`);
|
|
205139
205219
|
return true;
|
|
205140
205220
|
}
|
|
@@ -207461,7 +207541,13 @@ import {
|
|
|
207461
207541
|
|
|
207462
207542
|
// ../plugin/src/hooks/magic-context/m0-token-breakdown.ts
|
|
207463
207543
|
function computeM0BlockTokens(db, sessionId, args) {
|
|
207464
|
-
const {
|
|
207544
|
+
const {
|
|
207545
|
+
m0Text,
|
|
207546
|
+
projectIdentity,
|
|
207547
|
+
injectionBudgetTokens,
|
|
207548
|
+
memoryBlockCount,
|
|
207549
|
+
compartmentTokensOverride
|
|
207550
|
+
} = args;
|
|
207465
207551
|
const docsBlock = extractM0Block(m0Text, "project-docs");
|
|
207466
207552
|
const docsTokens = docsBlock ? estimateTokens(docsBlock) : 0;
|
|
207467
207553
|
const profileBlock = extractM0Block(m0Text, "user-profile");
|
|
@@ -207475,7 +207561,9 @@ function computeM0BlockTokens(db, sessionId, args) {
|
|
|
207475
207561
|
}
|
|
207476
207562
|
let compartmentTokens = 0;
|
|
207477
207563
|
const historyBlock = extractM0Block(m0Text, "session-history");
|
|
207478
|
-
if (
|
|
207564
|
+
if (typeof compartmentTokensOverride === "number" && Number.isFinite(compartmentTokensOverride) && compartmentTokensOverride >= 0) {
|
|
207565
|
+
compartmentTokens = compartmentTokensOverride;
|
|
207566
|
+
} else if (historyBlock) {
|
|
207479
207567
|
compartmentTokens = estimateTokens(historyBlock);
|
|
207480
207568
|
} else {
|
|
207481
207569
|
try {
|
|
@@ -207512,7 +207600,7 @@ function formatThresholdPercent(value) {
|
|
|
207512
207600
|
// package.json
|
|
207513
207601
|
var package_default = {
|
|
207514
207602
|
name: "@cortexkit/pi-magic-context",
|
|
207515
|
-
version: "0.32.
|
|
207603
|
+
version: "0.32.3",
|
|
207516
207604
|
type: "module",
|
|
207517
207605
|
description: "Pi coding agent extension for Magic Context — cross-session memory and context management",
|
|
207518
207606
|
main: "dist/index.js",
|
package/package.json
CHANGED