@cortexkit/magic-context 0.22.3 → 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.
Files changed (2) hide show
  1. package/dist/index.js +75 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -145656,6 +145656,9 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
145656
145656
  cached_m0_materialized_at INTEGER,
145657
145657
  cached_m0_session_facts_version INTEGER,
145658
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,
145659
145662
  cached_m0_last_baseline_end_message_id TEXT,
145660
145663
  upgrade_reminded_at INTEGER,
145661
145664
  pi_stable_id_scheme INTEGER
@@ -145847,6 +145850,9 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
145847
145850
  ensureColumn(db, "session_meta", "cached_m0_materialized_at", "INTEGER");
145848
145851
  ensureColumn(db, "session_meta", "cached_m0_session_facts_version", "INTEGER");
145849
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");
145850
145856
  ensureColumn(db, "session_meta", "cached_m0_last_baseline_end_message_id", "TEXT");
145851
145857
  ensureColumn(db, "session_meta", "upgrade_reminded_at", "INTEGER");
145852
145858
  db.exec(`
@@ -146057,7 +146063,7 @@ function closeDatabase() {
146057
146063
  }
146058
146064
  }
146059
146065
  }
146060
- var databases, persistenceByDatabase, persistenceErrorByDatabase, lastSchemaFenceRejection = null, LATEST_SUPPORTED_VERSION = 29, sqlitePragmaConfig;
146066
+ var databases, persistenceByDatabase, persistenceErrorByDatabase, lastSchemaFenceRejection = null, LATEST_SUPPORTED_VERSION = 30, sqlitePragmaConfig;
146061
146067
  var init_storage_db = __esm(async () => {
146062
146068
  init_data_path();
146063
146069
  init_logger();
@@ -146880,6 +146886,28 @@ var init_migrations = __esm(async () => {
146880
146886
  db.exec("ALTER TABLE notes ADD COLUMN anchor_ordinal INTEGER");
146881
146887
  }
146882
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
+ }
146883
146911
  }
146884
146912
  ];
146885
146913
  LATEST_MIGRATION_VERSION = MIGRATIONS.reduce((max, m) => Math.max(max, m.version), 0);
@@ -162358,6 +162386,7 @@ var init_magic_context = __esm(() => {
162358
162386
  model: DEFAULT_LOCAL_EMBEDDING_MODEL
162359
162387
  }).describe("Embedding provider configuration"),
162360
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."),
162361
162390
  caveman_text_compression: exports_external.object({
162362
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%)."),
162363
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.")
@@ -162660,25 +162689,56 @@ var init_config = __esm(() => {
162660
162689
  // ../plugin/src/features/magic-context/key-files/aft-availability.ts
162661
162690
  import { existsSync as existsSync16, readFileSync as readFileSync10 } from "node:fs";
162662
162691
  import { homedir as homedir9 } from "node:os";
162663
- 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";
162664
162694
  function parseConfig(path5) {
162665
162695
  if (!existsSync16(path5))
162666
162696
  return null;
162667
162697
  return import_comment_json6.parse(readFileSync10(path5, "utf-8"));
162668
162698
  }
162669
- function entryMatchesAft(entry) {
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) {
162670
162725
  const value = Array.isArray(entry) ? entry[0] : entry;
162671
- return typeof value === "string" && (value.includes("@cortexkit/aft") || value.includes("aft-opencode") || value.includes("aft-pi"));
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);
162672
162732
  }
162673
- function hasAftInArray(value) {
162674
- return Array.isArray(value) && value.some(entryMatchesAft);
162733
+ function hasAftInArray(value, configDir) {
162734
+ return Array.isArray(value) && value.some((entry) => entryMatchesAft(entry, configDir));
162675
162735
  }
162676
- function hasAftAtKeys(value, keys) {
162736
+ function hasAftAtKeys(value, keys, configDir) {
162677
162737
  if (!value || typeof value !== "object")
162678
162738
  return false;
162679
162739
  const record2 = value;
162680
162740
  for (const key of keys) {
162681
- if (hasAftInArray(record2[key]))
162741
+ if (hasAftInArray(record2[key], configDir))
162682
162742
  return true;
162683
162743
  }
162684
162744
  return false;
@@ -162695,7 +162755,8 @@ function getAftAvailability() {
162695
162755
  for (const path5 of opencodePaths) {
162696
162756
  try {
162697
162757
  const config2 = parseConfig(path5);
162698
- if (hasAftAtKeys(config2, ["plugin", "plugins", "mcp", "mcp_servers"])) {
162758
+ const configDir = join13(path5, "..");
162759
+ if (hasAftAtKeys(config2, ["plugin", "plugins", "mcp", "mcp_servers"], configDir)) {
162699
162760
  opencode = true;
162700
162761
  break;
162701
162762
  }
@@ -162705,12 +162766,13 @@ function getAftAvailability() {
162705
162766
  for (const path5 of piPaths) {
162706
162767
  try {
162707
162768
  const config2 = parseConfig(path5);
162708
- if (hasAftAtKeys(config2, ["packages", "extensions"])) {
162769
+ const configDir = join13(path5, "..");
162770
+ if (hasAftAtKeys(config2, ["packages", "extensions"], configDir)) {
162709
162771
  pi = true;
162710
162772
  break;
162711
162773
  }
162712
162774
  const agent = config2?.agent;
162713
- if (hasAftAtKeys(agent, ["packages", "extensions"])) {
162775
+ if (hasAftAtKeys(agent, ["packages", "extensions"], configDir)) {
162714
162776
  pi = true;
162715
162777
  break;
162716
162778
  }
@@ -162724,9 +162786,10 @@ function getAftAvailability() {
162724
162786
  checkedPaths
162725
162787
  };
162726
162788
  }
162727
- var import_comment_json6, overrideAvailability = null;
162789
+ var import_comment_json6, overrideAvailability = null, AFT_NAME_NEEDLES;
162728
162790
  var init_aft_availability = __esm(() => {
162729
162791
  import_comment_json6 = __toESM(require_src2(), 1);
162792
+ AFT_NAME_NEEDLES = ["@cortexkit/aft", "aft-opencode", "aft-pi"];
162730
162793
  });
162731
162794
 
162732
162795
  // ../plugin/src/features/magic-context/memory/embedding-probe.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/magic-context",
3
- "version": "0.22.3",
3
+ "version": "0.22.4",
4
4
  "description": "Unified CLI for Magic Context — setup, doctor, and migration across OpenCode and Pi",
5
5
  "keywords": [
6
6
  "opencode",