@cortexkit/magic-context 0.22.2 → 0.22.4
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 +93 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -144779,9 +144779,22 @@ var init_read_session_formatting = __esm(() => {
|
|
|
144779
144779
|
tokenizer = new src_default(exports_claude);
|
|
144780
144780
|
});
|
|
144781
144781
|
// ../plugin/src/hooks/magic-context/tag-content-primitives.ts
|
|
144782
|
-
|
|
144782
|
+
function stripTagPrefix(value) {
|
|
144783
|
+
let stripped = value;
|
|
144784
|
+
for (let pass = 0;pass < 8; pass++) {
|
|
144785
|
+
const prev = stripped;
|
|
144786
|
+
stripped = stripped.replace(MALFORMED_TAG_PREFIX_REGEX, "");
|
|
144787
|
+
stripped = stripped.replace(TAG_PREFIX_REGEX, "");
|
|
144788
|
+
if (stripped === prev)
|
|
144789
|
+
break;
|
|
144790
|
+
}
|
|
144791
|
+
return stripped;
|
|
144792
|
+
}
|
|
144793
|
+
var encoder, TAG_PREFIX_REGEX, MALFORMED_TAG_PREFIX_REGEX;
|
|
144783
144794
|
var init_tag_content_primitives = __esm(() => {
|
|
144784
144795
|
encoder = new TextEncoder;
|
|
144796
|
+
TAG_PREFIX_REGEX = /^(?:§\d+§\s*)+/;
|
|
144797
|
+
MALFORMED_TAG_PREFIX_REGEX = /^(?:§\d+">§(?:\d+§)?\s*)+/;
|
|
144785
144798
|
});
|
|
144786
144799
|
|
|
144787
144800
|
// ../plugin/src/hooks/magic-context/tag-part-guards.ts
|
|
@@ -144800,7 +144813,9 @@ function hasMeaningfulPart(part) {
|
|
|
144800
144813
|
return false;
|
|
144801
144814
|
const type = part.type;
|
|
144802
144815
|
if (type === "text") {
|
|
144803
|
-
|
|
144816
|
+
if (typeof part.text !== "string")
|
|
144817
|
+
return false;
|
|
144818
|
+
return stripTagPrefix(part.text).trim().length > 0;
|
|
144804
144819
|
}
|
|
144805
144820
|
if (typeof type !== "string")
|
|
144806
144821
|
return false;
|
|
@@ -144837,6 +144852,7 @@ class ToolMutationBatch {
|
|
|
144837
144852
|
}
|
|
144838
144853
|
var IGNORE_PART_TYPES;
|
|
144839
144854
|
var init_tool_drop_target = __esm(() => {
|
|
144855
|
+
init_tag_content_primitives();
|
|
144840
144856
|
IGNORE_PART_TYPES = new Set([
|
|
144841
144857
|
"thinking",
|
|
144842
144858
|
"reasoning",
|
|
@@ -145640,6 +145656,9 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
|
|
|
145640
145656
|
cached_m0_materialized_at INTEGER,
|
|
145641
145657
|
cached_m0_session_facts_version INTEGER,
|
|
145642
145658
|
cached_m0_upgrade_state TEXT,
|
|
145659
|
+
cached_m0_system_hash TEXT,
|
|
145660
|
+
cached_m0_tool_set_hash TEXT,
|
|
145661
|
+
cached_m0_model_key TEXT,
|
|
145643
145662
|
cached_m0_last_baseline_end_message_id TEXT,
|
|
145644
145663
|
upgrade_reminded_at INTEGER,
|
|
145645
145664
|
pi_stable_id_scheme INTEGER
|
|
@@ -145831,6 +145850,9 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
|
|
|
145831
145850
|
ensureColumn(db, "session_meta", "cached_m0_materialized_at", "INTEGER");
|
|
145832
145851
|
ensureColumn(db, "session_meta", "cached_m0_session_facts_version", "INTEGER");
|
|
145833
145852
|
ensureColumn(db, "session_meta", "cached_m0_upgrade_state", "TEXT");
|
|
145853
|
+
ensureColumn(db, "session_meta", "cached_m0_system_hash", "TEXT");
|
|
145854
|
+
ensureColumn(db, "session_meta", "cached_m0_tool_set_hash", "TEXT");
|
|
145855
|
+
ensureColumn(db, "session_meta", "cached_m0_model_key", "TEXT");
|
|
145834
145856
|
ensureColumn(db, "session_meta", "cached_m0_last_baseline_end_message_id", "TEXT");
|
|
145835
145857
|
ensureColumn(db, "session_meta", "upgrade_reminded_at", "INTEGER");
|
|
145836
145858
|
db.exec(`
|
|
@@ -146041,7 +146063,7 @@ function closeDatabase() {
|
|
|
146041
146063
|
}
|
|
146042
146064
|
}
|
|
146043
146065
|
}
|
|
146044
|
-
var databases, persistenceByDatabase, persistenceErrorByDatabase, lastSchemaFenceRejection = null, LATEST_SUPPORTED_VERSION =
|
|
146066
|
+
var databases, persistenceByDatabase, persistenceErrorByDatabase, lastSchemaFenceRejection = null, LATEST_SUPPORTED_VERSION = 30, sqlitePragmaConfig;
|
|
146045
146067
|
var init_storage_db = __esm(async () => {
|
|
146046
146068
|
init_data_path();
|
|
146047
146069
|
init_logger();
|
|
@@ -146864,6 +146886,28 @@ var init_migrations = __esm(async () => {
|
|
|
146864
146886
|
db.exec("ALTER TABLE notes ADD COLUMN anchor_ordinal INTEGER");
|
|
146865
146887
|
}
|
|
146866
146888
|
}
|
|
146889
|
+
},
|
|
146890
|
+
{
|
|
146891
|
+
version: 30,
|
|
146892
|
+
description: "HARD-bust m[0] markers: cached system/tool-set/model identity",
|
|
146893
|
+
up: (db) => {
|
|
146894
|
+
const hasSessionMeta = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='session_meta' LIMIT 1").get();
|
|
146895
|
+
if (!hasSessionMeta)
|
|
146896
|
+
return;
|
|
146897
|
+
ensureColumn(db, "session_meta", "cached_m0_system_hash", "TEXT");
|
|
146898
|
+
ensureColumn(db, "session_meta", "cached_m0_tool_set_hash", "TEXT");
|
|
146899
|
+
ensureColumn(db, "session_meta", "cached_m0_model_key", "TEXT");
|
|
146900
|
+
const columns = new Set(db.prepare("PRAGMA table_info(session_meta)").all().map((column) => column.name));
|
|
146901
|
+
if (columns.has("cached_m0_bytes")) {
|
|
146902
|
+
db.prepare(`UPDATE session_meta SET
|
|
146903
|
+
cached_m0_bytes = NULL,
|
|
146904
|
+
cached_m1_bytes = NULL,
|
|
146905
|
+
cached_m0_materialized_at = NULL,
|
|
146906
|
+
cached_m0_system_hash = NULL,
|
|
146907
|
+
cached_m0_tool_set_hash = NULL,
|
|
146908
|
+
cached_m0_model_key = NULL`).run();
|
|
146909
|
+
}
|
|
146910
|
+
}
|
|
146867
146911
|
}
|
|
146868
146912
|
];
|
|
146869
146913
|
LATEST_MIGRATION_VERSION = MIGRATIONS.reduce((max, m) => Math.max(max, m.version), 0);
|
|
@@ -162342,6 +162386,7 @@ var init_magic_context = __esm(() => {
|
|
|
162342
162386
|
model: DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
162343
162387
|
}).describe("Embedding provider configuration"),
|
|
162344
162388
|
temporal_awareness: exports_external.boolean().default(true).describe('Inject wall-clock gap markers (<!-- +Xm -->) between user messages where > 5 min elapsed since the previous message, and add start/end date attributes on compartments. Gives the agent a sense of session pacing and "how long ago" across multi-day sessions. Graduated from experimental.temporal_awareness; default: true (set false to opt out).'),
|
|
162389
|
+
keep_subagents: exports_external.boolean().default(false).describe("Debug: keep the child sessions Magic Context spawns for its own subagents (historian, dreamer, sidekick, memory-migration) instead of deleting them on success. Useful for short-term inspection/data collection — their full transcript (prompt, tool calls, token usage, output) stays in the host session store. Kept sessions accumulate until manually cleared; leave false for normal use. Requires a restart to take effect."),
|
|
162345
162390
|
caveman_text_compression: exports_external.object({
|
|
162346
162391
|
enabled: exports_external.boolean().default(false).describe("Apply deterministic caveman-style text compression to old conversation text. Only active when ctx_reduce_enabled=false. Compresses user/assistant text in oldest-first tiers: ultra (oldest 20%), full, lite, untouched (newest 40%)."),
|
|
162347
162392
|
min_chars: exports_external.number().min(100).max(1e4).default(500).describe("Text parts shorter than this (characters) stay untouched. Min 100, max 10000. Default: 500.")
|
|
@@ -162644,25 +162689,56 @@ var init_config = __esm(() => {
|
|
|
162644
162689
|
// ../plugin/src/features/magic-context/key-files/aft-availability.ts
|
|
162645
162690
|
import { existsSync as existsSync16, readFileSync as readFileSync10 } from "node:fs";
|
|
162646
162691
|
import { homedir as homedir9 } from "node:os";
|
|
162647
|
-
import { join as join13 } from "node:path";
|
|
162692
|
+
import { isAbsolute as isAbsolute2, join as join13, resolve as resolve3 } from "node:path";
|
|
162693
|
+
import { fileURLToPath } from "node:url";
|
|
162648
162694
|
function parseConfig(path5) {
|
|
162649
162695
|
if (!existsSync16(path5))
|
|
162650
162696
|
return null;
|
|
162651
162697
|
return import_comment_json6.parse(readFileSync10(path5, "utf-8"));
|
|
162652
162698
|
}
|
|
162653
|
-
function
|
|
162699
|
+
function stringMentionsAft(value) {
|
|
162700
|
+
return AFT_NAME_NEEDLES.some((needle) => value.includes(needle));
|
|
162701
|
+
}
|
|
162702
|
+
function resolveLocalEntryPackageName(value, configDir) {
|
|
162703
|
+
let dir = null;
|
|
162704
|
+
if (value.startsWith("file://")) {
|
|
162705
|
+
try {
|
|
162706
|
+
dir = fileURLToPath(value);
|
|
162707
|
+
} catch {
|
|
162708
|
+
return null;
|
|
162709
|
+
}
|
|
162710
|
+
} else if (value.startsWith("~/")) {
|
|
162711
|
+
dir = join13(homedir9(), value.slice(2));
|
|
162712
|
+
} else if (value.startsWith("/") || value.startsWith("./") || value.startsWith("../")) {
|
|
162713
|
+
dir = isAbsolute2(value) ? value : resolve3(configDir, value);
|
|
162714
|
+
} else {
|
|
162715
|
+
return null;
|
|
162716
|
+
}
|
|
162717
|
+
try {
|
|
162718
|
+
const pkg = JSON.parse(readFileSync10(join13(dir, "package.json"), "utf-8"));
|
|
162719
|
+
return typeof pkg.name === "string" ? pkg.name : null;
|
|
162720
|
+
} catch {
|
|
162721
|
+
return null;
|
|
162722
|
+
}
|
|
162723
|
+
}
|
|
162724
|
+
function entryMatchesAft(entry, configDir) {
|
|
162654
162725
|
const value = Array.isArray(entry) ? entry[0] : entry;
|
|
162655
|
-
|
|
162726
|
+
if (typeof value !== "string")
|
|
162727
|
+
return false;
|
|
162728
|
+
if (stringMentionsAft(value))
|
|
162729
|
+
return true;
|
|
162730
|
+
const name2 = resolveLocalEntryPackageName(value, configDir);
|
|
162731
|
+
return name2 != null && stringMentionsAft(name2);
|
|
162656
162732
|
}
|
|
162657
|
-
function hasAftInArray(value) {
|
|
162658
|
-
return Array.isArray(value) && value.some(entryMatchesAft);
|
|
162733
|
+
function hasAftInArray(value, configDir) {
|
|
162734
|
+
return Array.isArray(value) && value.some((entry) => entryMatchesAft(entry, configDir));
|
|
162659
162735
|
}
|
|
162660
|
-
function hasAftAtKeys(value, keys) {
|
|
162736
|
+
function hasAftAtKeys(value, keys, configDir) {
|
|
162661
162737
|
if (!value || typeof value !== "object")
|
|
162662
162738
|
return false;
|
|
162663
162739
|
const record2 = value;
|
|
162664
162740
|
for (const key of keys) {
|
|
162665
|
-
if (hasAftInArray(record2[key]))
|
|
162741
|
+
if (hasAftInArray(record2[key], configDir))
|
|
162666
162742
|
return true;
|
|
162667
162743
|
}
|
|
162668
162744
|
return false;
|
|
@@ -162679,7 +162755,8 @@ function getAftAvailability() {
|
|
|
162679
162755
|
for (const path5 of opencodePaths) {
|
|
162680
162756
|
try {
|
|
162681
162757
|
const config2 = parseConfig(path5);
|
|
162682
|
-
|
|
162758
|
+
const configDir = join13(path5, "..");
|
|
162759
|
+
if (hasAftAtKeys(config2, ["plugin", "plugins", "mcp", "mcp_servers"], configDir)) {
|
|
162683
162760
|
opencode = true;
|
|
162684
162761
|
break;
|
|
162685
162762
|
}
|
|
@@ -162689,12 +162766,13 @@ function getAftAvailability() {
|
|
|
162689
162766
|
for (const path5 of piPaths) {
|
|
162690
162767
|
try {
|
|
162691
162768
|
const config2 = parseConfig(path5);
|
|
162692
|
-
|
|
162769
|
+
const configDir = join13(path5, "..");
|
|
162770
|
+
if (hasAftAtKeys(config2, ["packages", "extensions"], configDir)) {
|
|
162693
162771
|
pi = true;
|
|
162694
162772
|
break;
|
|
162695
162773
|
}
|
|
162696
162774
|
const agent = config2?.agent;
|
|
162697
|
-
if (hasAftAtKeys(agent, ["packages", "extensions"])) {
|
|
162775
|
+
if (hasAftAtKeys(agent, ["packages", "extensions"], configDir)) {
|
|
162698
162776
|
pi = true;
|
|
162699
162777
|
break;
|
|
162700
162778
|
}
|
|
@@ -162708,9 +162786,10 @@ function getAftAvailability() {
|
|
|
162708
162786
|
checkedPaths
|
|
162709
162787
|
};
|
|
162710
162788
|
}
|
|
162711
|
-
var import_comment_json6, overrideAvailability = null;
|
|
162789
|
+
var import_comment_json6, overrideAvailability = null, AFT_NAME_NEEDLES;
|
|
162712
162790
|
var init_aft_availability = __esm(() => {
|
|
162713
162791
|
import_comment_json6 = __toESM(require_src2(), 1);
|
|
162792
|
+
AFT_NAME_NEEDLES = ["@cortexkit/aft", "aft-opencode", "aft-pi"];
|
|
162714
162793
|
});
|
|
162715
162794
|
|
|
162716
162795
|
// ../plugin/src/features/magic-context/memory/embedding-probe.ts
|