@cortexkit/magic-context 0.34.0 → 0.34.2

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 +260 -89
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -11863,9 +11863,10 @@ function migrateLegacyExperimental(rawConfig, warnings) {
11863
11863
  const exp = experimental;
11864
11864
  const hasUM = "user_memories" in exp;
11865
11865
  const hasPKF = "pin_key_files" in exp;
11866
+ const hasMural = "mural" in exp;
11866
11867
  const TOP_LEVEL_GRADUATED = ["temporal_awareness", "caveman_text_compression"];
11867
11868
  const MEMORY_GRADUATED = ["auto_search", "git_commit_indexing"];
11868
- const hasGraduated = TOP_LEVEL_GRADUATED.some((k) => (k in exp)) || MEMORY_GRADUATED.some((k) => (k in exp));
11869
+ const hasGraduated = TOP_LEVEL_GRADUATED.some((k) => (k in exp)) || MEMORY_GRADUATED.some((k) => (k in exp)) || hasMural;
11869
11870
  if (!hasUM && !hasPKF && !hasGraduated) {
11870
11871
  return rawConfig;
11871
11872
  }
@@ -11873,6 +11874,15 @@ function migrateLegacyExperimental(rawConfig, warnings) {
11873
11874
  const dreamer = typeof patched.dreamer === "object" && patched.dreamer !== null ? { ...patched.dreamer } : {};
11874
11875
  const memory = typeof patched.memory === "object" && patched.memory !== null ? { ...patched.memory } : {};
11875
11876
  const newExperimental = { ...exp };
11877
+ const coerceToObject = (value) => {
11878
+ if (typeof value === "boolean") {
11879
+ return { enabled: value };
11880
+ }
11881
+ if (typeof value === "object" && value !== null) {
11882
+ return { ...value };
11883
+ }
11884
+ return;
11885
+ };
11876
11886
  const relocate = (key, dest, destLabel) => {
11877
11887
  if (!(key in exp))
11878
11888
  return;
@@ -11893,15 +11903,20 @@ function migrateLegacyExperimental(rawConfig, warnings) {
11893
11903
  relocate(key, patched, "");
11894
11904
  for (const key of MEMORY_GRADUATED)
11895
11905
  relocate(key, memory, "memory.");
11896
- const coerceToObject = (value) => {
11897
- if (typeof value === "boolean") {
11898
- return { enabled: value };
11899
- }
11900
- if (typeof value === "object" && value !== null) {
11901
- return { ...value };
11906
+ if (hasMural) {
11907
+ const oldMural = coerceToObject(exp.mural);
11908
+ const existingMural = patched.mural;
11909
+ if (existingMural === undefined) {
11910
+ patched.mural = oldMural ?? exp.mural;
11911
+ warnings.push('Deprecated "experimental.mural"; use top-level "mural" instead (migrated in memory; run `doctor` to persist).');
11912
+ } else if (oldMural !== undefined && typeof existingMural === "object" && existingMural !== null && !Array.isArray(existingMural)) {
11913
+ patched.mural = {
11914
+ ...oldMural,
11915
+ ...existingMural
11916
+ };
11902
11917
  }
11903
- return;
11904
- };
11918
+ delete newExperimental.mural;
11919
+ }
11905
11920
  if (hasUM) {
11906
11921
  const oldUM = coerceToObject(exp.user_memories);
11907
11922
  if (oldUM !== undefined) {
@@ -26915,12 +26930,10 @@ var init_magic_context = __esm(() => {
26915
26930
  MagicContextConfigSchema = exports_external.object({
26916
26931
  enabled: exports_external.boolean().default(true).describe("Enable magic context (default: true)"),
26917
26932
  allow_home_project: exports_external.boolean().default(false).describe("Allow Magic Context sessions launched from the exact canonical home directory. The home session uses its deterministic dir: identity so pre-gate memories reconnect. USER-LEVEL ONLY: project config is ignored. The home identity is excluded from registry seed exports, never resolves descendants by containment, and cannot join a workspace."),
26918
- experimental: exports_external.object({
26919
- mural: exports_external.object({
26920
- enabled: exports_external.boolean().default(false),
26921
- model: exports_external.string().trim().min(1).optional().describe("Model for the compress-cues task that compresses each memory into a mural cue. The mural image itself is rendered deterministically (no author model).")
26922
- }).default({ enabled: false }).describe("Experimental mural: a single deterministically-rendered image of project memories that did not fit the context budget. Cues are compressed per-memory by the compress-cues dreamer task.")
26923
- }).default({ mural: { enabled: false } }).describe("Experimental feature switches. User and project configuration are both accepted."),
26933
+ mural: exports_external.object({
26934
+ enabled: exports_external.boolean().default(false),
26935
+ model: exports_external.string().trim().min(1).optional().describe("Model for the compress-cues task that compresses each memory into a mural cue. The mural image itself is rendered deterministically (no author model).")
26936
+ }).default({ enabled: false }).describe("Experimental mural: a single deterministically-rendered image of project memories that did not fit the context budget. Cues are compressed per-memory by the compress-cues dreamer task."),
26924
26937
  transform_mode: exports_external.enum(["ts", "rust"]).default("ts").describe('Experimental: routes the entire Magic Context runtime for the project through the ck-mc Rust module over subc (requires user-level `subc` config); "ts" is the current TypeScript pipeline.'),
26925
26938
  auto_update: exports_external.boolean().optional().describe("Enable automatic npm self-update checks for the OpenCode plugin. Security: USER-only in config loader, so hostile project configs cannot suppress updates."),
26926
26939
  language: exports_external.string().trim().toLowerCase().refine((s) => isValidLanguageCode(s), 'language must be a 2-letter ISO 639-1 code (e.g. "tr", "es", "de")').optional().describe("Output language for Magic Context's generated content and guidance, as a " + '2-letter ISO 639-1 code (e.g. "tr", "es", "de", "ja", "pt"). When set, the ' + "historian, dreamer, sidekick, and the agent-guidance block instruct the model to " + "write its PROSE in this language while keeping all structural tokens (XML tags, " + "the five memory category names, code identifiers, file paths) in English. " + "USER-LEVEL ONLY (ignored in project config for security). Unset = today's " + "behavior (model mirrors the conversation; English scaffolding). Changing it " + "triggers one cache re-materialization; existing compartments/memories keep their " + "original language until naturally rewritten."),
@@ -27187,6 +27200,17 @@ function stripUnsafeProjectConfigFields(projectRaw) {
27187
27200
  warnings.push(`Ignoring historian.${removed.join("/")} from project config ` + "(security: historian model selection is user-level only; a repository cannot force extra compaction cost).");
27188
27201
  }
27189
27202
  }
27203
+ const mural = projectRaw.mural;
27204
+ if (isPlainObject2(mural) && "model" in mural) {
27205
+ delete mural.model;
27206
+ warnings.push("Ignoring mural.model from project config (security: the mural cue-compressor model is a user-level setting; a repository cannot choose where project memory is sent).");
27207
+ }
27208
+ const experimental = projectRaw.experimental;
27209
+ const legacyMural = isPlainObject2(experimental) ? experimental.mural : undefined;
27210
+ if (isPlainObject2(legacyMural) && "model" in legacyMural) {
27211
+ delete legacyMural.model;
27212
+ warnings.push("Ignoring experimental.mural.model from project config (security: the mural cue-compressor model is a user-level setting; use user-level mural.model).");
27213
+ }
27190
27214
  for (const agentKey of HIDDEN_AGENT_KEYS) {
27191
27215
  const block2 = projectRaw[agentKey];
27192
27216
  if (!isPlainObject2(block2))
@@ -32996,6 +33020,8 @@ var init_module_transport = __esm(() => {
32996
33020
  init_data_path();
32997
33021
  });
32998
33022
  // ../plugin/src/shared/rpc-utils.ts
33023
+ import { execFileSync as execFileSync4 } from "node:child_process";
33024
+ import { readFileSync as readFileSync9 } from "node:fs";
32999
33025
  function isPidAlive(pid) {
33000
33026
  if (!Number.isInteger(pid) || pid <= 0)
33001
33027
  return false;
@@ -33006,6 +33032,76 @@ function isPidAlive(pid) {
33006
33032
  return err.code === "EPERM";
33007
33033
  }
33008
33034
  }
33035
+ function parseLinuxProcessStartTime(statContent, uptimeContent) {
33036
+ const closingCommandName = statContent.lastIndexOf(")");
33037
+ if (closingCommandName < 0)
33038
+ return null;
33039
+ const statFields = statContent.slice(closingCommandName + 1).trim().split(/\s+/);
33040
+ const startTimeTicks = Number(statFields[19]);
33041
+ const uptimeSeconds = Number(uptimeContent.trim().split(/\s+/)[0]);
33042
+ if (!Number.isFinite(startTimeTicks) || startTimeTicks < 0 || !Number.isFinite(uptimeSeconds) || uptimeSeconds < 0) {
33043
+ return null;
33044
+ }
33045
+ const processStartTime = rpcIdentityNowMs() - uptimeSeconds * 1000 + startTimeTicks / LINUX_CLOCK_TICKS_PER_SECOND * 1000;
33046
+ return Number.isFinite(processStartTime) ? processStartTime : null;
33047
+ }
33048
+ function readLinuxProcessStartTime(pid) {
33049
+ try {
33050
+ const statContent = String(rpcIdentityReadFileSync(`/proc/${pid}/stat`, "utf8"));
33051
+ const uptimeContent = String(rpcIdentityReadFileSync("/proc/uptime", "utf8"));
33052
+ return parseLinuxProcessStartTime(statContent, uptimeContent);
33053
+ } catch {
33054
+ return null;
33055
+ }
33056
+ }
33057
+ function readPsProcessStartTime(pid) {
33058
+ try {
33059
+ const output = rpcIdentityExecFileSync("ps", ["-p", String(pid), "-o", "lstart="], {
33060
+ encoding: "utf8",
33061
+ timeout: PS_PROBE_TIMEOUT_MS
33062
+ });
33063
+ const processStartTime = Date.parse(String(output).trim());
33064
+ return Number.isFinite(processStartTime) ? processStartTime : null;
33065
+ } catch {
33066
+ return null;
33067
+ }
33068
+ }
33069
+ function readLinuxProcessCommand(pid) {
33070
+ try {
33071
+ return String(rpcIdentityReadFileSync(`/proc/${pid}/cmdline`, "utf8"));
33072
+ } catch {
33073
+ return null;
33074
+ }
33075
+ }
33076
+ function readPsProcessCommand(pid) {
33077
+ try {
33078
+ const output = rpcIdentityExecFileSync("ps", ["-p", String(pid), "-o", "command="], {
33079
+ encoding: "utf8",
33080
+ timeout: PS_PROBE_TIMEOUT_MS
33081
+ });
33082
+ return String(output);
33083
+ } catch {
33084
+ return null;
33085
+ }
33086
+ }
33087
+ function commandLooksLikeOpenCode(command) {
33088
+ const normalized = command.toLowerCase();
33089
+ return OPEN_CODE_COMMAND_MARKERS.some((marker) => normalized.includes(marker));
33090
+ }
33091
+ function isPidIdentityPlausible(record2) {
33092
+ if (!Number.isInteger(record2.pid) || record2.pid <= 0)
33093
+ return false;
33094
+ if (Number.isFinite(record2.started_at) && record2.started_at > 0) {
33095
+ const processStartTime = rpcIdentityPlatform === "linux" ? readLinuxProcessStartTime(record2.pid) : readPsProcessStartTime(record2.pid);
33096
+ if (processStartTime === null)
33097
+ return true;
33098
+ return processStartTime <= record2.started_at + RPC_IDENTITY_SKEW_TOLERANCE_MS;
33099
+ }
33100
+ const command = rpcIdentityPlatform === "linux" ? readLinuxProcessCommand(record2.pid) : readPsProcessCommand(record2.pid);
33101
+ if (command === null)
33102
+ return true;
33103
+ return commandLooksLikeOpenCode(command);
33104
+ }
33009
33105
  function parseRpcPortFile(content, fallbackPid = 0) {
33010
33106
  const trimmed = content.trim();
33011
33107
  if (!trimmed)
@@ -33037,7 +33133,13 @@ function parseRpcPortFile(content, fallbackPid = 0) {
33037
33133
  function isValidPort(port) {
33038
33134
  return Number.isInteger(port) && port > 0 && port <= 65535;
33039
33135
  }
33040
- var init_rpc_utils = () => {};
33136
+ var RPC_IDENTITY_SKEW_TOLERANCE_MS = 120000, LINUX_CLOCK_TICKS_PER_SECOND = 100, PS_PROBE_TIMEOUT_MS = 1000, OPEN_CODE_COMMAND_MARKERS, rpcIdentityReadFileSync, rpcIdentityExecFileSync, rpcIdentityPlatform, rpcIdentityNowMs = () => Date.now();
33137
+ var init_rpc_utils = __esm(() => {
33138
+ OPEN_CODE_COMMAND_MARKERS = ["opencode", "node", "bun", "electron"];
33139
+ rpcIdentityReadFileSync = readFileSync9;
33140
+ rpcIdentityExecFileSync = execFileSync4;
33141
+ rpcIdentityPlatform = process.platform;
33142
+ });
33041
33143
  // ../plugin/src/hooks/magic-context/compartment-parser.ts
33042
33144
  function makeTierOpenRegex(n2) {
33043
33145
  return new RegExp(`<p${n2}\\s*(/?)>`);
@@ -33498,7 +33600,7 @@ function installLatestAuthorityTriggers(db) {
33498
33600
  `);
33499
33601
  }
33500
33602
  }
33501
- var MIGRATIONS, LATEST_MIGRATION_VERSION;
33603
+ var FORK_MIGRATION_VERSION_FLOOR = 1e4, MIGRATIONS, LATEST_MIGRATION_VERSION;
33502
33604
  var init_migrations = __esm(() => {
33503
33605
  init_compartment_parser();
33504
33606
  init_logger();
@@ -35421,6 +35523,15 @@ var init_migrations = __esm(() => {
35421
35523
  ensureColumn(db, "session_meta", "detected_context_limit_provenance", "TEXT NOT NULL DEFAULT 'unknown'");
35422
35524
  }
35423
35525
  }
35526
+ },
35527
+ {
35528
+ version: 75,
35529
+ description: "persist mural cue validation rejection latches",
35530
+ up(db) {
35531
+ if (!tableExists(db, "memories"))
35532
+ return;
35533
+ ensureColumn(db, "memories", "mural_cue_rejection_count", "INTEGER NOT NULL DEFAULT 0");
35534
+ }
35424
35535
  }
35425
35536
  ];
35426
35537
  LATEST_MIGRATION_VERSION = MIGRATIONS.reduce((max, m3) => Math.max(max, m3.version), 0);
@@ -167912,7 +168023,8 @@ import {
167912
168023
  mkdirSync as mkdirSync7,
167913
168024
  mkdtempSync,
167914
168025
  readdirSync as readdirSync2,
167915
- readFileSync as readFileSync9,
168026
+ readFileSync as readFileSync10,
168027
+ statSync as statSync7,
167916
168028
  unlinkSync as unlinkSync2
167917
168029
  } from "node:fs";
167918
168030
  import { basename as basename3, dirname as dirname10, join as join12 } from "node:path";
@@ -167921,27 +168033,60 @@ function getPersistedSchemaVersion(db) {
167921
168033
  if (!hasMigrationsTable) {
167922
168034
  return 0;
167923
168035
  }
167924
- const row = db.prepare("SELECT MAX(version) AS version FROM schema_migrations").get();
168036
+ const row = db.prepare("SELECT COALESCE(MAX(version), 0) AS version FROM schema_migrations WHERE version < ?").get(FORK_MIGRATION_VERSION_FLOOR);
167925
168037
  return row?.version ?? 0;
167926
168038
  }
167927
- function unreadableDiscovery(path4) {
168039
+ function unreadableDiscovery(path4, arm) {
167928
168040
  return {
167929
168041
  state: "unreadable",
167930
168042
  serverPids: [],
167931
168043
  staleFiles: [],
167932
- unreadableFile: path4
168044
+ unreadableFile: path4,
168045
+ unreadableArm: arm
167933
168046
  };
167934
168047
  }
168048
+ function invalidDiscoveryReason(raw) {
168049
+ const trimmed = raw.trim();
168050
+ if (trimmed.startsWith("{")) {
168051
+ try {
168052
+ const parsed = JSON.parse(trimmed);
168053
+ if ("pid" in parsed) {
168054
+ const pid = Number(parsed.pid);
168055
+ if (!Number.isInteger(pid) || pid <= 0)
168056
+ return "invalid-pid";
168057
+ }
168058
+ } catch {}
168059
+ }
168060
+ return "parse-invalid";
168061
+ }
168062
+ function classifyJunkDiscovery(portFile, raw, staleFiles) {
168063
+ let mtimeMs;
168064
+ try {
168065
+ mtimeMs = rpcDiscoveryFs.statSync(portFile).mtimeMs;
168066
+ } catch (error51) {
168067
+ if (error51.code === "ENOENT")
168068
+ return null;
168069
+ return unreadableDiscovery(portFile, "io");
168070
+ }
168071
+ const ageMs = Date.now() - mtimeMs;
168072
+ if (!Number.isFinite(ageMs) || ageMs < RPC_DISCOVERY_PARSE_GRACE_MS) {
168073
+ return unreadableDiscovery(portFile, "parse");
168074
+ }
168075
+ staleFiles.push(portFile);
168076
+ const reason = invalidDiscoveryReason(raw);
168077
+ log3(`[magic-context] removing stale RPC discovery file ${portFile}: ${reason} record older than 10 minutes`);
168078
+ return null;
168079
+ }
167935
168080
  function inspectRpcServerDiscovery(storageDir) {
167936
168081
  const rpcRoot = join12(storageDir, "rpc");
167937
168082
  let projectEntries;
167938
168083
  try {
167939
- projectEntries = readdirSync2(rpcRoot, { withFileTypes: true });
168084
+ projectEntries = rpcDiscoveryFs.readdirSync(rpcRoot, { withFileTypes: true });
167940
168085
  } catch (error51) {
167941
168086
  if (error51.code === "ENOENT") {
167942
168087
  return { state: "absent", serverPids: [], staleFiles: [] };
167943
168088
  }
167944
- return unreadableDiscovery(rpcRoot);
168089
+ return unreadableDiscovery(rpcRoot, "io");
167945
168090
  }
167946
168091
  const portFiles = [];
167947
168092
  for (const projectEntry of projectEntries) {
@@ -167950,9 +168095,11 @@ function inspectRpcServerDiscovery(storageDir) {
167950
168095
  const projectDir = join12(rpcRoot, projectEntry.name);
167951
168096
  let entries;
167952
168097
  try {
167953
- entries = readdirSync2(projectDir);
167954
- } catch {
167955
- return unreadableDiscovery(projectDir);
168098
+ entries = rpcDiscoveryFs.readdirSync(projectDir);
168099
+ } catch (error51) {
168100
+ if (error51.code === "ENOENT")
168101
+ continue;
168102
+ return unreadableDiscovery(projectDir, "io");
167956
168103
  }
167957
168104
  for (const entry of entries) {
167958
168105
  if (entry === "port" || entry.startsWith("port-") && entry.endsWith(".json")) {
@@ -167968,32 +168115,38 @@ function inspectRpcServerDiscovery(storageDir) {
167968
168115
  for (const portFile of portFiles) {
167969
168116
  let raw;
167970
168117
  try {
167971
- raw = readFileSync9(portFile, "utf8");
167972
- } catch {
167973
- return unreadableDiscovery(portFile);
168118
+ raw = rpcDiscoveryFs.readFileSync(portFile, "utf8");
168119
+ } catch (error51) {
168120
+ if (error51.code === "ENOENT")
168121
+ continue;
168122
+ return unreadableDiscovery(portFile, "io");
167974
168123
  }
167975
168124
  const filename = basename3(portFile);
167976
168125
  const pidFromName = /^port-(\d+)/.exec(filename)?.[1];
167977
- const record2 = parseRpcPortFile(raw, pidFromName ? Number(pidFromName) : 0);
168126
+ const fallbackPid = pidFromName ? Number(pidFromName) : 0;
168127
+ const record2 = parseRpcPortFile(raw, fallbackPid);
167978
168128
  if (!record2 || !Number.isInteger(record2.pid) || record2.pid <= 0) {
167979
- return unreadableDiscovery(portFile);
168129
+ const junk = classifyJunkDiscovery(portFile, raw, staleFiles);
168130
+ if (junk)
168131
+ return junk;
168132
+ continue;
167980
168133
  }
167981
- if (isPidAlive(record2.pid))
168134
+ if (isPidAlive(record2.pid) && isPidIdentityPlausible(record2))
167982
168135
  pids.add(record2.pid);
167983
168136
  else
167984
168137
  staleFiles.push(portFile);
167985
168138
  }
167986
- const serverPids = [...pids].sort((a3, b2) => a3 - b2);
167987
- if (serverPids.length > 0) {
167988
- return { state: "live", serverPids, staleFiles };
167989
- }
167990
168139
  for (const staleFile of staleFiles) {
167991
168140
  try {
167992
- unlinkSync2(staleFile);
168141
+ rpcDiscoveryFs.unlinkSync(staleFile);
167993
168142
  } catch {
167994
- return unreadableDiscovery(staleFile);
168143
+ return unreadableDiscovery(staleFile, "io");
167995
168144
  }
167996
168145
  }
168146
+ const serverPids = [...pids].sort((a3, b2) => a3 - b2);
168147
+ if (serverPids.length > 0) {
168148
+ return { state: "live", serverPids, staleFiles };
168149
+ }
167997
168150
  return { state: "stale", serverPids: [], staleFiles };
167998
168151
  }
167999
168152
  function getLiveMigrationBlockingProcesses(storageDir) {
@@ -168002,7 +168155,7 @@ function getLiveMigrationBlockingProcesses(storageDir) {
168002
168155
  return [];
168003
168156
  return discovery.serverPids.map((pid) => ({ harness: "OpenCode server", pid }));
168004
168157
  }
168005
- var databases, pendingAsyncOpens, persistenceByDatabase, persistenceErrorByDatabase, pathByDatabase, LATEST_SUPPORTED_VERSION = 74, PERMISSIONS_ENFORCEABLE;
168158
+ var databases, pendingAsyncOpens, persistenceByDatabase, persistenceErrorByDatabase, pathByDatabase, LATEST_SUPPORTED_VERSION = 75, PERMISSIONS_ENFORCEABLE, RPC_DISCOVERY_PARSE_GRACE_MS, defaultRpcDiscoveryFs, rpcDiscoveryFs;
168006
168159
  var init_storage_db = __esm(async () => {
168007
168160
  init_data_path();
168008
168161
  init_logger();
@@ -168020,6 +168173,14 @@ var init_storage_db = __esm(async () => {
168020
168173
  persistenceErrorByDatabase = new WeakMap;
168021
168174
  pathByDatabase = new WeakMap;
168022
168175
  PERMISSIONS_ENFORCEABLE = process.platform !== "win32";
168176
+ RPC_DISCOVERY_PARSE_GRACE_MS = 10 * 60 * 1000;
168177
+ defaultRpcDiscoveryFs = {
168178
+ readdirSync: (path4, options) => options?.withFileTypes ? readdirSync2(path4, { withFileTypes: true }) : readdirSync2(path4),
168179
+ readFileSync: (path4, encoding) => String(readFileSync10(path4, encoding)),
168180
+ statSync: (path4) => ({ mtimeMs: statSync7(path4).mtimeMs }),
168181
+ unlinkSync: (path4) => unlinkSync2(path4)
168182
+ };
168183
+ rpcDiscoveryFs = defaultRpcDiscoveryFs;
168023
168184
  });
168024
168185
 
168025
168186
  // src/lib/database-access.ts
@@ -170037,9 +170198,9 @@ import {
170037
170198
  chmodSync as chmodSync3,
170038
170199
  existsSync as existsSync19,
170039
170200
  mkdirSync as mkdirSync8,
170040
- readFileSync as readFileSync10,
170201
+ readFileSync as readFileSync11,
170041
170202
  renameSync as renameSync3,
170042
- statSync as statSync7,
170203
+ statSync as statSync8,
170043
170204
  writeFileSync as writeFileSync6
170044
170205
  } from "node:fs";
170045
170206
  import { dirname as dirname11, join as join17 } from "node:path";
@@ -170075,8 +170236,8 @@ function writeTuiConfigAtomic(configPath, config2) {
170075
170236
  const tmpPath = `${configPath}.tmp`;
170076
170237
  writeFileSync6(tmpPath, body);
170077
170238
  try {
170078
- if (statSync7(configPath, { throwIfNoEntry: false })?.isFile()) {
170079
- chmodSync3(tmpPath, statSync7(configPath).mode & 511);
170239
+ if (statSync8(configPath, { throwIfNoEntry: false })?.isFile()) {
170240
+ chmodSync3(tmpPath, statSync8(configPath).mode & 511);
170080
170241
  }
170081
170242
  } catch {}
170082
170243
  renameSync3(tmpPath, configPath);
@@ -170096,7 +170257,7 @@ function ensureTuiPluginEntry(options = {}) {
170096
170257
  const configPath = resolveTuiConfigPath(options.configDir);
170097
170258
  let config2 = {};
170098
170259
  if (existsSync19(configPath)) {
170099
- const raw = readFileSync10(configPath, "utf-8");
170260
+ const raw = readFileSync11(configPath, "utf-8");
170100
170261
  config2 = import_comment_json7.parse(raw) ?? {};
170101
170262
  }
170102
170263
  const plugins = Array.isArray(config2.plugin) ? [...config2.plugin] : [];
@@ -170356,7 +170517,7 @@ var init_redaction2 = __esm(() => {
170356
170517
  });
170357
170518
 
170358
170519
  // src/lib/diagnostics-opencode.ts
170359
- import { existsSync as existsSync20, readdirSync as readdirSync3, readFileSync as readFileSync11, statSync as statSync8 } from "node:fs";
170520
+ import { existsSync as existsSync20, readdirSync as readdirSync3, readFileSync as readFileSync12, statSync as statSync9 } from "node:fs";
170360
170521
  import { createRequire as createRequire2 } from "node:module";
170361
170522
  import { homedir as homedir14 } from "node:os";
170362
170523
  import { join as join18 } from "node:path";
@@ -170378,7 +170539,7 @@ function getPluginCacheInfo() {
170378
170539
  for (const installedPkgPath of getOpenCodePluginPackageJsonPaths()) {
170379
170540
  try {
170380
170541
  if (existsSync20(installedPkgPath)) {
170381
- const pkg = JSON.parse(readFileSync11(installedPkgPath, "utf-8"));
170542
+ const pkg = JSON.parse(readFileSync12(installedPkgPath, "utf-8"));
170382
170543
  cached2 = typeof pkg.version === "string" ? pkg.version : undefined;
170383
170544
  if (cached2)
170384
170545
  break;
@@ -170395,7 +170556,7 @@ function getStorageDir() {
170395
170556
  }
170396
170557
  function fileSize(path6) {
170397
170558
  try {
170398
- return existsSync20(path6) ? statSync8(path6).size : 0;
170559
+ return existsSync20(path6) ? statSync9(path6).size : 0;
170399
170560
  } catch {
170400
170561
  return 0;
170401
170562
  }
@@ -170410,7 +170571,7 @@ function readConfig2(path6) {
170410
170571
  if (!existsSync20(path6))
170411
170572
  return { value: null };
170412
170573
  try {
170413
- const raw = readFileSync11(path6, "utf-8");
170574
+ const raw = readFileSync12(path6, "utf-8");
170414
170575
  const value = import_comment_json8.parse(raw);
170415
170576
  return { value };
170416
170577
  } catch (error51) {
@@ -170435,7 +170596,7 @@ function configHasPluginEntry(config2) {
170435
170596
  }
170436
170597
  function parseHistorianDumpMeta(path6) {
170437
170598
  try {
170438
- const xml = readFileSync11(path6, "utf-8");
170599
+ const xml = readFileSync12(path6, "utf-8");
170439
170600
  const parsed = parseCompartmentOutput(xml);
170440
170601
  const factCountByCategory = {};
170441
170602
  for (const fact of parsed.facts) {
@@ -170472,7 +170633,7 @@ function listDumpsInDir(dir, limit) {
170472
170633
  return { count: 0, recent: [] };
170473
170634
  try {
170474
170635
  const entries = readdirSync3(dir).filter((name2) => name2.endsWith(".xml")).map((name2) => {
170475
- const stat = statSync8(join18(dir, name2));
170636
+ const stat = statSync9(join18(dir, name2));
170476
170637
  return {
170477
170638
  name: name2,
170478
170639
  mtime: stat.mtimeMs,
@@ -170678,7 +170839,7 @@ async function collectDiagnostics() {
170678
170839
  const storageDirPath = getStorageDir();
170679
170840
  const contextDbPath = join18(storageDirPath, "context.db");
170680
170841
  const logPath = getMagicContextLogPath2("opencode");
170681
- const logFileSize = existsSync20(logPath) ? statSync8(logPath).size : 0;
170842
+ const logFileSize = existsSync20(logPath) ? statSync9(logPath).size : 0;
170682
170843
  let compactionEnabled = false;
170683
170844
  try {
170684
170845
  compactionEnabled = isCompactionEnabled(loadPluginConfig(process.cwd()));
@@ -171194,7 +171355,7 @@ var init_issue_body = __esm(() => {
171194
171355
  });
171195
171356
 
171196
171357
  // src/lib/logs-opencode.ts
171197
- import { readFileSync as readFileSync12, writeFileSync as writeFileSync7 } from "node:fs";
171358
+ import { readFileSync as readFileSync13, writeFileSync as writeFileSync7 } from "node:fs";
171198
171359
  import { join as join20 } from "node:path";
171199
171360
  function sanitizeLogContent(content) {
171200
171361
  return sanitizeDiagnosticText(content);
@@ -171237,7 +171398,7 @@ function filterLogLinesBySession(lines, sessionId) {
171237
171398
  }
171238
171399
  async function bundleIssueReport(report, description, title, sessionFilter = null) {
171239
171400
  const LOG_TAIL_LINES = 400;
171240
- const allLogLines = report.logFile.exists ? readFileSync12(report.logFile.path, "utf-8").split(/\r?\n/) : [];
171401
+ const allLogLines = report.logFile.exists ? readFileSync13(report.logFile.path, "utf-8").split(/\r?\n/) : [];
171241
171402
  const logLines = filterLogLinesBySession(allLogLines, sessionFilter);
171242
171403
  const recentLog = sanitizeLogContent(logLines.slice(-LOG_TAIL_LINES).join(`
171243
171404
  `)).trim();
@@ -171577,6 +171738,15 @@ function formatFailClosedBlockingProcesses(processes) {
171577
171738
  }
171578
171739
  function formatFailClosedBlockingMessage(reason) {
171579
171740
  if (reason.kind === "migration_guard") {
171741
+ if (reason.unreadableFile) {
171742
+ const arm = reason.unreadableArm ?? "io";
171743
+ const recovery = arm === "io" ? `If no OpenCode server is running, it is safe to delete ${reason.unreadableFile} and retry.` : `The file may be a recent incomplete write; retry after the file is older than the ten-minute grace window, or stop OpenCode before deleting it.`;
171744
+ return [
171745
+ `Magic Context cannot migrate the shared database because RPC discovery file ${reason.unreadableFile} is uncertain (${arm} arm), so the absence of a live OpenCode server cannot be proven.`,
171746
+ recovery,
171747
+ `Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
171748
+ ].join(" ");
171749
+ }
171580
171750
  return [
171581
171751
  `Magic Context cannot migrate the shared database because ${formatFailClosedBlockingProcesses(reason.blockingProcesses)} may be running an older Magic Context build that would fail against the migrated database.`,
171582
171752
  "Restart the blocking process (it will pick up the new build and migrate on start), or shut it down and retry.",
@@ -171585,7 +171755,7 @@ function formatFailClosedBlockingMessage(reason) {
171585
171755
  }
171586
171756
  if (reason.kind === "schema_fence") {
171587
171757
  return [
171588
- `Magic Context cannot operate: this Magic Context build is older than the database; upgrade/restart this harness (database schema v${reason.persistedVersion}, build supports through v${reason.supportedVersion}).`,
171758
+ `Magic Context cannot operate: this Magic Context build is older than the database; upgrade/restart this harness (upstream migration lane v${reason.persistedVersion}, build supports through v${reason.supportedVersion}).`,
171589
171759
  `Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
171590
171760
  ].join(" ");
171591
171761
  }
@@ -171610,7 +171780,7 @@ function checkStorageVersionFence(versions2, options = {}) {
171610
171780
  if (databaseVersion > supportedVersion) {
171611
171781
  return {
171612
171782
  alarm: true,
171613
- message: `Storage schema fence alarm: context.db is v${databaseVersion}, but this build supports through v${supportedVersion}. ` + `${STALE_BUILD_RESTART_INSTRUCTION}.`
171783
+ message: `Upstream migration fence alarm: context.db is v${databaseVersion}, but this build supports through v${supportedVersion}. ` + `${STALE_BUILD_RESTART_INSTRUCTION}.`
171614
171784
  };
171615
171785
  }
171616
171786
  if (databaseVersion < supportedVersion) {
@@ -171627,12 +171797,12 @@ function checkStorageVersionFence(versions2, options = {}) {
171627
171797
  }
171628
171798
  return {
171629
171799
  alarm: false,
171630
- message: `Storage schema migrations pending: context.db is v${databaseVersion}; this build supports through v${supportedVersion}.`
171800
+ message: `Upstream migrations pending: context.db is v${databaseVersion}; this build supports through v${supportedVersion}.`
171631
171801
  };
171632
171802
  }
171633
171803
  return {
171634
171804
  alarm: false,
171635
- message: `Storage schema fence: context.db and this build are both v${supportedVersion}.`
171805
+ message: `Upstream migration fence: context.db and this build are both v${supportedVersion}.`
171636
171806
  };
171637
171807
  }
171638
171808
  function readStorageVersions(db) {
@@ -171651,13 +171821,13 @@ var init_storage_versions = __esm(async () => {
171651
171821
  });
171652
171822
 
171653
171823
  // src/commands/doctor-opencode-cache.ts
171654
- import { existsSync as existsSync22, readFileSync as readFileSync13, rmSync as rmSync2 } from "node:fs";
171824
+ import { existsSync as existsSync22, readFileSync as readFileSync14, rmSync as rmSync2 } from "node:fs";
171655
171825
  function readCachedPluginVersion(pluginCacheDir) {
171656
171826
  try {
171657
171827
  const installedPkgPath = getOpenCodePluginPackageJsonPath(pluginCacheDir);
171658
171828
  if (!existsSync22(installedPkgPath))
171659
171829
  return;
171660
- const pkg = JSON.parse(readFileSync13(installedPkgPath, "utf-8"));
171830
+ const pkg = JSON.parse(readFileSync14(installedPkgPath, "utf-8"));
171661
171831
  return typeof pkg.version === "string" ? pkg.version : undefined;
171662
171832
  } catch {
171663
171833
  return;
@@ -171734,7 +171904,7 @@ var init_doctor_opencode_cache = __esm(() => {
171734
171904
 
171735
171905
  // src/commands/doctor-opencode.ts
171736
171906
  import { execSync as execSync2, spawnSync as spawnSync3 } from "node:child_process";
171737
- import { existsSync as existsSync23, readFileSync as readFileSync14, statSync as statSync9 } from "node:fs";
171907
+ import { existsSync as existsSync23, readFileSync as readFileSync15, statSync as statSync10 } from "node:fs";
171738
171908
  import { createRequire as createRequire4 } from "node:module";
171739
171909
  import { homedir as homedir15 } from "node:os";
171740
171910
  import { join as join21 } from "node:path";
@@ -171844,7 +172014,7 @@ function collectNpmReleaseAgeWarnings() {
171844
172014
  if (!existsSync23(npmrcPath))
171845
172015
  return ageWarnings;
171846
172016
  try {
171847
- const npmrc = readFileSync14(npmrcPath, "utf-8");
172017
+ const npmrc = readFileSync15(npmrcPath, "utf-8");
171848
172018
  for (const line of npmrc.split(`
171849
172019
  `)) {
171850
172020
  const trimmed = line.trim();
@@ -171988,7 +172158,7 @@ async function checkEmbeddingConfig(magicContextConfigPath) {
171988
172158
  }
171989
172159
  let rawText;
171990
172160
  try {
171991
- rawText = readFileSync14(magicContextConfigPath, "utf-8");
172161
+ rawText = readFileSync15(magicContextConfigPath, "utf-8");
171992
172162
  } catch {
171993
172163
  log2.warn("Could not read magic-context.jsonc for embedding check");
171994
172164
  return { issues: 1 };
@@ -172197,7 +172367,7 @@ async function runDoctor(options = {}) {
172197
172367
  if (existsSync23(paths.magicContextConfig)) {
172198
172368
  pass(`Magic Context config: ${paths.magicContextConfig}`);
172199
172369
  try {
172200
- const raw = readFileSync14(paths.magicContextConfig, "utf-8");
172370
+ const raw = readFileSync15(paths.magicContextConfig, "utf-8");
172201
172371
  const substituted = substituteConfigVariables({
172202
172372
  text: raw,
172203
172373
  configPath: paths.magicContextConfig
@@ -172224,7 +172394,7 @@ async function runDoctor(options = {}) {
172224
172394
  }
172225
172395
  if (existsSync23(paths.magicContextConfig)) {
172226
172396
  try {
172227
- const mcRaw = readFileSync14(paths.magicContextConfig, "utf-8");
172397
+ const mcRaw = readFileSync15(paths.magicContextConfig, "utf-8");
172228
172398
  const mcConfig = import_comment_json9.parse(mcRaw);
172229
172399
  let mcChanged = false;
172230
172400
  const experimental = mcConfig.experimental;
@@ -172309,6 +172479,7 @@ async function runDoctor(options = {}) {
172309
172479
  if (experimental) {
172310
172480
  relocateGraduated("temporal_awareness", mcConfig, "");
172311
172481
  relocateGraduated("caveman_text_compression", mcConfig, "");
172482
+ relocateGraduated("mural", mcConfig, "");
172312
172483
  const memoryDest = mcConfig.memory ?? {};
172313
172484
  relocateGraduated("auto_search", memoryDest, "memory.");
172314
172485
  relocateGraduated("git_commit_indexing", memoryDest, "memory.");
@@ -172341,7 +172512,7 @@ async function runDoctor(options = {}) {
172341
172512
  }
172342
172513
  if (paths.opencodeConfigFormat !== "none") {
172343
172514
  try {
172344
- const raw = readFileSync14(paths.opencodeConfig, "utf-8");
172515
+ const raw = readFileSync15(paths.opencodeConfig, "utf-8");
172345
172516
  const config2 = import_comment_json9.parse(raw);
172346
172517
  const rawPlugins = Array.isArray(config2?.plugin) ? config2.plugin : [];
172347
172518
  const existingIdx = rawPlugins.findIndex((entry) => matchesPluginEntry(entry, OPENCODE_PLUGIN_NAME) || isDevPathPluginEntry(entry));
@@ -172427,7 +172598,7 @@ async function runDoctor(options = {}) {
172427
172598
  fixed++;
172428
172599
  } else if (existsSync23(paths.tuiConfig)) {
172429
172600
  try {
172430
- const tuiRaw = readFileSync14(paths.tuiConfig, "utf-8");
172601
+ const tuiRaw = readFileSync15(paths.tuiConfig, "utf-8");
172431
172602
  const tuiConfig = import_comment_json9.parse(tuiRaw);
172432
172603
  const tuiRawPlugins = Array.isArray(tuiConfig?.plugin) ? tuiConfig.plugin : [];
172433
172604
  const tuiIdx = tuiRawPlugins.findIndex((entry) => matchesPluginEntry(entry, OPENCODE_PLUGIN_NAME) || isDevPathPluginEntry(entry));
@@ -172478,7 +172649,7 @@ async function runDoctor(options = {}) {
172478
172649
  }
172479
172650
  if (existsSync23(paths.magicContextConfig)) {
172480
172651
  try {
172481
- const mcRaw = readFileSync14(paths.magicContextConfig, "utf-8");
172652
+ const mcRaw = readFileSync15(paths.magicContextConfig, "utf-8");
172482
172653
  const mcConfig = import_comment_json9.parse(mcRaw);
172483
172654
  const warning = checkUserMemoriesDreamerCompatibility(mcConfig);
172484
172655
  if (warning) {
@@ -172601,7 +172772,7 @@ async function runDoctor(options = {}) {
172601
172772
  }
172602
172773
  const logPath = getMagicContextLogPath2("opencode");
172603
172774
  if (existsSync23(logPath)) {
172604
- const logStat = statSync9(logPath);
172775
+ const logStat = statSync10(logPath);
172605
172776
  const sizeKb = (logStat.size / 1024).toFixed(0);
172606
172777
  log2.info(`Log file: ${logPath} (${sizeKb} KB)`);
172607
172778
  } else {
@@ -172680,7 +172851,7 @@ var init_doctor_opencode = __esm(async () => {
172680
172851
  });
172681
172852
 
172682
172853
  // ../pi-plugin/src/config/index.ts
172683
- import { existsSync as existsSync24, readFileSync as readFileSync15 } from "node:fs";
172854
+ import { existsSync as existsSync24, readFileSync as readFileSync16 } from "node:fs";
172684
172855
  function getProjectConfigPaths(cwd) {
172685
172856
  const basePath = cortexKitProjectConfigBasePath(cwd);
172686
172857
  return [`${basePath}.jsonc`, `${basePath}.json`];
@@ -172697,7 +172868,7 @@ function resolvePiLegacyFallback(sources) {
172697
172868
  }
172698
172869
  function loadConfigFile(path6, scope) {
172699
172870
  try {
172700
- const rawText = readFileSync15(path6, "utf-8");
172871
+ const rawText = readFileSync16(path6, "utf-8");
172701
172872
  const substituted = substituteConfigVariables({
172702
172873
  text: rawText,
172703
172874
  configPath: path6,
@@ -172904,7 +173075,7 @@ var init_config2 = __esm(() => {
172904
173075
 
172905
173076
  // src/lib/diagnostics-pi.ts
172906
173077
  import { createHash as createHash4 } from "node:crypto";
172907
- import { existsSync as existsSync25, readdirSync as readdirSync4, readFileSync as readFileSync16, statSync as statSync10 } from "node:fs";
173078
+ import { existsSync as existsSync25, readdirSync as readdirSync4, readFileSync as readFileSync17, statSync as statSync11 } from "node:fs";
172908
173079
  import { createRequire as createRequire5 } from "node:module";
172909
173080
  import { homedir as homedir16, userInfo as userInfo2 } from "node:os";
172910
173081
  import { join as join22 } from "node:path";
@@ -172922,7 +173093,7 @@ function getSelfVersion3() {
172922
173093
  }
172923
173094
  function fileSize2(path6) {
172924
173095
  try {
172925
- return existsSync25(path6) ? statSync10(path6).size : 0;
173096
+ return existsSync25(path6) ? statSync11(path6).size : 0;
172926
173097
  } catch {
172927
173098
  return 0;
172928
173099
  }
@@ -172978,7 +173149,7 @@ function readJsonc(path6) {
172978
173149
  return { value: {} };
172979
173150
  try {
172980
173151
  return {
172981
- value: import_comment_json11.parse(readFileSync16(path6, "utf-8"))
173152
+ value: import_comment_json11.parse(readFileSync17(path6, "utf-8"))
172982
173153
  };
172983
173154
  } catch (error51) {
172984
173155
  return {
@@ -173030,7 +173201,7 @@ function collectPiRecentSessions() {
173030
173201
  }
173031
173202
  for (const file2 of files) {
173032
173203
  try {
173033
- const mtime = statSync10(join22(slugDir, file2)).mtimeMs;
173204
+ const mtime = statSync11(join22(slugDir, file2)).mtimeMs;
173034
173205
  const sessionId = file2.replace(/\.jsonl$/, "");
173035
173206
  candidates.push({ sessionId, directory, mtime });
173036
173207
  } catch {}
@@ -173048,7 +173219,7 @@ function collectPiRecentSessions() {
173048
173219
  }
173049
173220
  function parseHistorianDumpMeta2(path6) {
173050
173221
  try {
173051
- const xml = readFileSync16(path6, "utf-8");
173222
+ const xml = readFileSync17(path6, "utf-8");
173052
173223
  const parsed = parseCompartmentOutput(xml);
173053
173224
  const factCountByCategory = {};
173054
173225
  for (const fact of parsed.facts) {
@@ -173085,7 +173256,7 @@ function listDumpsInDir2(dir, limit) {
173085
173256
  return { count: 0, recent: [] };
173086
173257
  try {
173087
173258
  const entries = readdirSync4(dir).filter((name2) => name2.endsWith(".xml")).map((name2) => {
173088
- const stat = statSync10(join22(dir, name2));
173259
+ const stat = statSync11(join22(dir, name2));
173089
173260
  return {
173090
173261
  name: name2,
173091
173262
  mtime: stat.mtimeMs,
@@ -173159,7 +173330,7 @@ async function collectDiagnostics2(cwd = process.cwd()) {
173159
173330
  const storageDirPath = getMagicContextStorageDir();
173160
173331
  const dbPath = join22(storageDirPath, "context.db");
173161
173332
  const logPath = getMagicContextLogPath2("pi");
173162
- const logFileSize = existsSync25(logPath) ? statSync10(logPath).size : 0;
173333
+ const logFileSize = existsSync25(logPath) ? statSync11(logPath).size : 0;
173163
173334
  const otherPiExtensions = packages.filter((entry) => !isPiMagicContextPackageEntry(entry)).map(describePiPackageEntry);
173164
173335
  const recentSessions = collectPiRecentSessions();
173165
173336
  const historianDumps = collectPiHistorianDumps(recentSessions);
@@ -173293,7 +173464,7 @@ var init_diagnostics_pi = __esm(() => {
173293
173464
  });
173294
173465
 
173295
173466
  // src/lib/logs-pi.ts
173296
- import { readFileSync as readFileSync17, writeFileSync as writeFileSync8 } from "node:fs";
173467
+ import { readFileSync as readFileSync18, writeFileSync as writeFileSync8 } from "node:fs";
173297
173468
  import { join as join23 } from "node:path";
173298
173469
  function sanitizeLogContent2(content) {
173299
173470
  return sanitizeString2(content);
@@ -173323,7 +173494,7 @@ function filterLogLinesBySession2(lines, sessionId) {
173323
173494
  }
173324
173495
  async function bundleIssueReport2(report, description, title, options = {}) {
173325
173496
  const LOG_TAIL_LINES = 400;
173326
- const allLogLines = report.logFile.exists ? readFileSync17(report.logFile.path, "utf-8").split(/\r?\n/) : [];
173497
+ const allLogLines = report.logFile.exists ? readFileSync18(report.logFile.path, "utf-8").split(/\r?\n/) : [];
173327
173498
  const logLines = filterLogLinesBySession2(allLogLines, options.sessionFilter ?? null);
173328
173499
  const recentLog = sanitizeLogContent2(logLines.slice(-LOG_TAIL_LINES).join(`
173329
173500
  `)).trim();
@@ -173370,8 +173541,8 @@ var init_logs_pi = __esm(() => {
173370
173541
  });
173371
173542
 
173372
173543
  // src/commands/doctor-pi.ts
173373
- import { execFileSync as execFileSync4, spawnSync as spawnSync4 } from "node:child_process";
173374
- import { existsSync as existsSync26, mkdirSync as mkdirSync9, readdirSync as readdirSync5, readFileSync as readFileSync18, rmSync as rmSync3, statSync as statSync11 } from "node:fs";
173544
+ import { execFileSync as execFileSync5, spawnSync as spawnSync4 } from "node:child_process";
173545
+ import { existsSync as existsSync26, mkdirSync as mkdirSync9, readdirSync as readdirSync5, readFileSync as readFileSync19, rmSync as rmSync3, statSync as statSync12 } from "node:fs";
173375
173546
  import { createRequire as createRequire6 } from "node:module";
173376
173547
  import { homedir as homedir17 } from "node:os";
173377
173548
  import { dirname as dirname13, isAbsolute as isAbsolute4, join as join24 } from "node:path";
@@ -173410,7 +173581,7 @@ function selfVersion() {
173410
173581
  }
173411
173582
  function getLatestNpmVersion(packageName) {
173412
173583
  try {
173413
- return execFileSync4("npm", ["view", packageName, "version"], {
173584
+ return execFileSync5("npm", ["view", packageName, "version"], {
173414
173585
  encoding: "utf-8",
173415
173586
  stdio: ["ignore", "pipe", "ignore"],
173416
173587
  timeout: 1e4
@@ -173464,7 +173635,7 @@ function summarize(results) {
173464
173635
  function readJsonc2(path6) {
173465
173636
  try {
173466
173637
  return {
173467
- value: import_comment_json12.parse(readFileSync18(path6, "utf-8"))
173638
+ value: import_comment_json12.parse(readFileSync19(path6, "utf-8"))
173468
173639
  };
173469
173640
  } catch (error51) {
173470
173641
  return {
@@ -173497,7 +173668,7 @@ function readConfigForEmbedding(path6, isProjectConfig) {
173497
173668
  if (!existsSync26(path6))
173498
173669
  return null;
173499
173670
  try {
173500
- const rawText = readFileSync18(path6, "utf-8");
173671
+ const rawText = readFileSync19(path6, "utf-8");
173501
173672
  const substituted = substituteConfigVariables({
173502
173673
  text: rawText,
173503
173674
  configPath: path6,
@@ -173587,7 +173758,7 @@ function findPiMagicContextCacheDirs(cwd, expectedVersion, force = false) {
173587
173758
  return;
173588
173759
  let stat;
173589
173760
  try {
173590
- stat = statSync11(path6);
173761
+ stat = statSync12(path6);
173591
173762
  } catch {
173592
173763
  return;
173593
173764
  }
@@ -173596,7 +173767,7 @@ function findPiMagicContextCacheDirs(cwd, expectedVersion, force = false) {
173596
173767
  const packageJson = join24(path6, "package.json");
173597
173768
  if (existsSync26(packageJson)) {
173598
173769
  try {
173599
- const pkg = JSON.parse(readFileSync18(packageJson, "utf-8"));
173770
+ const pkg = JSON.parse(readFileSync19(packageJson, "utf-8"));
173600
173771
  const name2 = typeof pkg.name === "string" ? pkg.name : "";
173601
173772
  const version2 = typeof pkg.version === "string" ? pkg.version : undefined;
173602
173773
  if (name2 === PACKAGE_NAME) {
@@ -173850,9 +174021,9 @@ async function runHealthChecks(options) {
173850
174021
  }
173851
174022
  const logPath = getMagicContextLogPath2("pi");
173852
174023
  if (existsSync26(logPath)) {
173853
- const stat = statSync11(logPath);
174024
+ const stat = statSync12(logPath);
173854
174025
  const sizeKb = (stat.size / 1024).toFixed(0);
173855
- const lines = readFileSync18(logPath, "utf-8").split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
174026
+ const lines = readFileSync19(logPath, "utf-8").split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
173856
174027
  add(results, "info", `Log file: ${logPath} (${sizeKb} KB)`);
173857
174028
  const lastLine = lines.at(-1);
173858
174029
  add(results, "info", `Last plugin log line: ${lastLine ? sanitizeDiagnosticText(lastLine) : "<empty log>"}`);
@@ -174130,7 +174301,7 @@ var init_doctor_pi = __esm(async () => {
174130
174301
  probeEmbeddingEndpoint,
174131
174302
  openExistingContextDatabase,
174132
174303
  now: () => new Date,
174133
- execFileSync: execFileSync4,
174304
+ execFileSync: execFileSync5,
174134
174305
  spawnSync: spawnSync4
174135
174306
  };
174136
174307
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cortexkit/magic-context",
3
- "version": "0.34.0",
4
- "description": "Unified CLI for Magic Context \u2014 setup, doctor, and migration across OpenCode and Pi",
3
+ "version": "0.34.2",
4
+ "description": "Unified CLI for Magic Context — setup, doctor, and migration across OpenCode and Pi",
5
5
  "keywords": [
6
6
  "opencode",
7
7
  "opencode-plugin",