@cortexkit/magic-context 0.49.86 → 0.49.89

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 +287 -104
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3021,6 +3021,7 @@ import {
3021
3021
  readdirSync,
3022
3022
  readlinkSync as readlinkSync2,
3023
3023
  readSync as readSync2,
3024
+ realpathSync as realpathSync2,
3024
3025
  renameSync,
3025
3026
  rmdirSync,
3026
3027
  rmSync,
@@ -3028,6 +3029,7 @@ import {
3028
3029
  writeFileSync as writeFileSync2,
3029
3030
  writeSync as writeSync2
3030
3031
  } from "node:fs";
3032
+ import { homedir as homedir3 } from "node:os";
3031
3033
  import { basename as basename2, dirname as dirname3, join as join2, resolve as resolve2 } from "node:path";
3032
3034
  function setStoragePrivatePermissionEnforcement(enforce) {
3033
3035
  enforcePrivateStoragePermissions = enforce;
@@ -3133,11 +3135,77 @@ function readStoragePermissionCertificate(marker) {
3133
3135
  closeSync2(fd);
3134
3136
  }
3135
3137
  }
3138
+ function inspectLinkedStorageRoot(root, rootStat) {
3139
+ const parent = dirname3(root);
3140
+ if (root === parent)
3141
+ return { skipped: "filesystem-root" };
3142
+ try {
3143
+ if (root === realpathSync2(homedir3()))
3144
+ return { skipped: "home-folder" };
3145
+ } catch (error) {
3146
+ if (error.code !== "ENOENT")
3147
+ throw error;
3148
+ }
3149
+ if (lstatSync2(parent).dev !== rootStat.dev)
3150
+ return { skipped: "mount-point" };
3151
+ const entries = readdirSync(root);
3152
+ const foreignEntries = entries.filter((name) => name !== ".DS_Store" && !MAGIC_CONTEXT_STORAGE_ENTRIES.some((entry) => typeof entry === "string" ? entry === name : entry.test(name))).length;
3153
+ return foreignEntries === 0 ? { entries } : { skipped: foreignEntries };
3154
+ }
3136
3155
  function tightenStorageTreeSync(directory, dbPath = join2(directory, "context.db")) {
3137
3156
  if (process.platform === "win32") {
3138
3157
  return { tightened: 0, failures: 0 };
3139
3158
  }
3140
- const root = resolve2(directory);
3159
+ const enforce = shouldEnforcePrivateStoragePermissions();
3160
+ const startupPath = resolve2(directory);
3161
+ let root = startupPath;
3162
+ let rootStat;
3163
+ let rootLink;
3164
+ let linkedEntries;
3165
+ try {
3166
+ rootStat = lstatSync2(root);
3167
+ } catch {
3168
+ if (enforce)
3169
+ return { tightened: 0, failures: 1 };
3170
+ }
3171
+ if (rootStat?.isSymbolicLink()) {
3172
+ try {
3173
+ root = realpathSync2(startupPath);
3174
+ rootStat = lstatSync2(root);
3175
+ if (rootStat.isDirectory() && enforce) {
3176
+ const eligibility = inspectLinkedStorageRoot(root, rootStat);
3177
+ if ("skipped" in eligibility) {
3178
+ return {
3179
+ tightened: 0,
3180
+ failures: 0,
3181
+ rootLink: { path: startupPath, target: root, skipped: eligibility.skipped }
3182
+ };
3183
+ }
3184
+ linkedEntries = eligibility.entries;
3185
+ }
3186
+ } catch (error) {
3187
+ if (!enforce)
3188
+ return { tightened: 0, failures: 0 };
3189
+ const failure = error.code ?? String(error);
3190
+ return { tightened: 0, failures: 1, rootLink: { path: startupPath, failure } };
3191
+ }
3192
+ if (!rootStat.isDirectory()) {
3193
+ if (!enforce)
3194
+ return { tightened: 0, failures: 0 };
3195
+ return {
3196
+ tightened: 0,
3197
+ failures: 1,
3198
+ rootLink: {
3199
+ path: startupPath,
3200
+ failure: "not a directory",
3201
+ nonDirectoryTarget: root
3202
+ }
3203
+ };
3204
+ }
3205
+ rootLink = { path: startupPath, target: root };
3206
+ dbPath = join2(root, basename2(dbPath));
3207
+ storagePermissionRoots.add(startupPath);
3208
+ }
3141
3209
  const marker = join2(root, STORAGE_PERMISSIONS_MARKER);
3142
3210
  let tightened = 0;
3143
3211
  let failures = 0;
@@ -3150,20 +3218,14 @@ function tightenStorageTreeSync(directory, dbPath = join2(directory, "context.db
3150
3218
  return false;
3151
3219
  }
3152
3220
  };
3153
- if (!shouldEnforcePrivateStoragePermissions()) {
3221
+ if (!enforce) {
3154
3222
  storagePermissionRoots.add(root);
3155
3223
  if (!removeMarker())
3156
3224
  failures++;
3157
- return { tightened, failures };
3225
+ return { tightened, failures, ...rootLink && { rootLink } };
3158
3226
  }
3159
- let rootStat;
3160
- try {
3161
- rootStat = lstatSync2(root);
3162
- if (!rootStat.isDirectory())
3163
- return { tightened, failures: 1 };
3164
- } catch {
3227
+ if (!rootStat?.isDirectory())
3165
3228
  return { tightened, failures: 1 };
3166
- }
3167
3229
  storagePermissionRoots.add(root);
3168
3230
  let certificate;
3169
3231
  let discardMarker = false;
@@ -3243,13 +3305,16 @@ function tightenStorageTreeSync(directory, dbPath = join2(directory, "context.db
3243
3305
  return;
3244
3306
  let entries;
3245
3307
  try {
3246
- entries = readdirSync(entryPath);
3308
+ entries = (entryPath === root ? linkedEntries : undefined) ?? readdirSync(entryPath);
3247
3309
  } catch {
3248
3310
  failures++;
3249
3311
  return;
3250
3312
  }
3251
- for (const entry of entries)
3313
+ for (const entry of entries) {
3314
+ if (entryPath === root && linkedEntries && markerRemoved && entry === STORAGE_PERMISSIONS_MARKER)
3315
+ continue;
3252
3316
  visit(join2(entryPath, entry));
3317
+ }
3253
3318
  };
3254
3319
  if (certificate) {
3255
3320
  visit(root, false, false, rootStat);
@@ -3297,9 +3362,9 @@ function tightenStorageTreeSync(directory, dbPath = join2(directory, "context.db
3297
3362
  }
3298
3363
  }
3299
3364
  }
3300
- return { tightened, failures };
3365
+ return { tightened, failures, ...rootLink && { rootLink } };
3301
3366
  }
3302
- var enforcePrivateStoragePermissions = true, STORAGE_PERMISSIONS_POLICY_VERSION = 1, STORAGE_PERMISSIONS_MARKER, STORAGE_PERMISSIONS_MARKER_BYTES, STORAGE_PERMISSIONS_MARKER_MAX_AGE_MS, LEGACY_FENCE_TEMP_MIN_AGE_MS, storagePermissionRoots;
3367
+ var enforcePrivateStoragePermissions = true, STORAGE_PERMISSIONS_POLICY_VERSION = 1, STORAGE_PERMISSIONS_MARKER, STORAGE_PERMISSIONS_MARKER_BYTES, STORAGE_PERMISSIONS_MARKER_MAX_AGE_MS, LEGACY_FENCE_TEMP_MIN_AGE_MS, MAGIC_CONTEXT_STORAGE_ENTRIES, storagePermissionRoots;
3303
3368
  var init_storage_permissions = __esm(() => {
3304
3369
  init_rpc_utils();
3305
3370
  STORAGE_PERMISSIONS_MARKER = `.storage-permissions-v${STORAGE_PERMISSIONS_POLICY_VERSION}`;
@@ -3307,6 +3372,36 @@ var init_storage_permissions = __esm(() => {
3307
3372
  `);
3308
3373
  STORAGE_PERMISSIONS_MARKER_MAX_AGE_MS = 24 * 60 * 60000;
3309
3374
  LEGACY_FENCE_TEMP_MIN_AGE_MS = 10 * 60000;
3375
+ MAGIC_CONTEXT_STORAGE_ENTRIES = [
3376
+ "context.db",
3377
+ "context.db-wal",
3378
+ "context.db-shm",
3379
+ "context.db-journal",
3380
+ "store.db",
3381
+ "store.db-wal",
3382
+ "store.db-shm",
3383
+ "store.db-journal",
3384
+ STORAGE_PERMISSIONS_MARKER,
3385
+ "models",
3386
+ "logs",
3387
+ "backups",
3388
+ "config-backups",
3389
+ "lkg-recovery-fences",
3390
+ "rpc",
3391
+ "project-identities",
3392
+ "heap-snapshots",
3393
+ "host-profiler",
3394
+ "pi-served-array-digests",
3395
+ "pi-served-array-bodies",
3396
+ "pi-served-tag-numbers",
3397
+ "window-reports.jsonl",
3398
+ "window-reports.jsonl.1",
3399
+ /^(?:last_announced_version|last-update-check\.json|pending-plugin-update\.json|model-context-limits-(?:opencode|opencode2)\.json)(?:\.[1-9]\d*\.[a-f0-9]{12}\.tmp)?$/,
3400
+ /^identity-merge-backup-[A-Za-z0-9]{6}$/,
3401
+ /^context\.db\.bak-\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z$/,
3402
+ /^context\.db\.corrupt-(?:backup|original)-\d{8}T\d{9}Z(?:-[1-9]\d{0,3})?(?:-wal|-shm)?$/,
3403
+ /^context\.db\.recovering-\d{8}T\d{9}Z-[1-9]\d*(?:-[1-9]\d{0,3})?(?:\.(?:count-source|recover-source|(?:fresh\.)?db)(?:-wal|-shm)?|\.sql)$/
3404
+ ];
3310
3405
  storagePermissionRoots = new Set;
3311
3406
  });
3312
3407
 
@@ -3679,13 +3774,13 @@ var init_jsonc_edit = __esm(() => {
3679
3774
 
3680
3775
  // ../plugin/src/config/migrate-config-location.ts
3681
3776
  import { existsSync as existsSync3, readFileSync as readFileSync4, rmSync as rmSync2, statSync as statSync2, unlinkSync as unlinkSync2 } from "node:fs";
3682
- import { homedir as homedir3 } from "node:os";
3777
+ import { homedir as homedir4 } from "node:os";
3683
3778
  import { basename as basename3, dirname as dirname4, isAbsolute as isAbsolute2, join as join3 } from "node:path";
3684
3779
  function homeDir() {
3685
3780
  if (process.platform === "win32") {
3686
- return process.env.USERPROFILE || process.env.HOME || homedir3();
3781
+ return process.env.USERPROFILE || process.env.HOME || homedir4();
3687
3782
  }
3688
- return process.env.HOME || homedir3();
3783
+ return process.env.HOME || homedir4();
3689
3784
  }
3690
3785
  function configHome() {
3691
3786
  const xdg = process.env.XDG_CONFIG_HOME;
@@ -10958,7 +11053,7 @@ var init_agent_overrides = __esm(() => {
10958
11053
  });
10959
11054
 
10960
11055
  // ../plugin/src/config/schema/magic-context.ts
10961
- import { homedir as homedir4 } from "node:os";
11056
+ import { homedir as homedir5 } from "node:os";
10962
11057
  function defaultTaskConfig(task) {
10963
11058
  const base = { schedule: DEFAULT_TASK_SCHEDULES[task] };
10964
11059
  if (task === "review-user-memories")
@@ -10970,9 +11065,9 @@ function defaultTaskConfig(task) {
10970
11065
  function expandConfigPath(value) {
10971
11066
  const trimmed = value.trim();
10972
11067
  if (trimmed === "~")
10973
- return homedir4();
11068
+ return homedir5();
10974
11069
  if (trimmed.startsWith("~/"))
10975
- return `${homedir4()}/${trimmed.slice(2)}`;
11070
+ return `${homedir5()}/${trimmed.slice(2)}`;
10976
11071
  return trimmed;
10977
11072
  }
10978
11073
  var DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE = 65, EXECUTE_THRESHOLD_CAP_MESSAGE = "execute_threshold is capped at 90% for cache safety: output capacity is reserved from the usable context window, and the remaining 10% absorbs mid-turn growth before the absolute 95% emergency wall. Use a value between 20 and 90.", DEFAULT_HISTORIAN_TIMEOUT_MS = 600000, DEFAULT_HISTORY_BUDGET_PERCENTAGE = 0.15, PROTECTED_TOKENS_MIN = 4000, DEFAULT_LOCAL_EMBEDDING_MODEL = "Xenova/all-MiniLM-L6-v2", PiThinkingLevelSchema, OmpThinkingLevelSchema, PiConfigSchema, PromptSurfacePresetSchema, PromptSurfaceModelKeySchema, PromptSurfaceToolKeySchema, PromptSurfaceConfigSchema, PER_HARNESS_MIGRATION_INVENTORY, PER_HARNESS_MODEL_KEYS, OcEntryObjectSchema, OcEntrySchema, PiEntryObjectSchema, PiEntrySchema, OmpEntryObjectSchema, OmpEntrySchema, OpenCodeHarnessBlockSchema, PiHarnessBlockSchema, OmpHarnessBlockSchema, OpenCodeTaskExecutionSchema, PiTaskExecutionSchema, OmpTaskExecutionSchema, DreamerOpenCodeHarnessBlockSchema, DreamerPiHarnessBlockSchema, DreamerOmpHarnessBlockSchema, ProfileOpenCodeModelBlockSchema, ProfilePiModelBlockSchema, ProfileOmpModelBlockSchema, ProfileHistorianSchema, ProfileDreamerSchema, ConfigProfileSchema, ConfigProfilesSchema, CronScheduleSchema, DreamTaskBaseConfigSchema, DREAM_TASK_PROMOTION_DEFAULTS, PromotionThresholdSchema, PrimerPromotionThresholdSchema, DreamTaskConfigSchema, ReviewUserMemoriesTaskConfigSchema, PromotePrimersTaskConfigSchema, RetrospectiveTaskConfigSchema, DEFAULT_TASK_SCHEDULES, DreamTasksSchema, AgentMetadataSchema, DreamerConfigSchema, HistorianConfigSchema, EmbeddingFallbackProviderSchema, BaseEmbeddingConfigSchema, EmbeddingConfigSchema, RerankConfigSchema, MagicContextConfigSchema, LIVE_RELOAD_CONFIG_PATHS;
@@ -12279,7 +12374,7 @@ import {
12279
12374
  linkSync,
12280
12375
  openSync as openSync3,
12281
12376
  readFileSync as readFileSync5,
12282
- realpathSync as realpathSync2,
12377
+ realpathSync as realpathSync3,
12283
12378
  renameSync as renameSync2,
12284
12379
  statSync as statSync3,
12285
12380
  unlinkSync as unlinkSync3,
@@ -12567,7 +12662,7 @@ function loadRawConfigFile(options) {
12567
12662
  }
12568
12663
  let temporaryPath;
12569
12664
  try {
12570
- const writePath = realpathSync2(options.configPath);
12665
+ const writePath = realpathSync3(options.configPath);
12571
12666
  const mode = options.tier === "user" ? 384 : statSync3(writePath).mode & 511;
12572
12667
  writeExclusiveBackup(backupPath, observedBytes, mode);
12573
12668
  temporaryPath = writeTemporaryCandidate(writePath, migration.bytes, mode);
@@ -12683,10 +12778,10 @@ var RUST_COMPACTION_OFF_WARNING = "compaction-off mode does not support rust tra
12683
12778
 
12684
12779
  // ../plugin/src/config/variable.ts
12685
12780
  import { existsSync as existsSync5, readFileSync as readFileSync6 } from "node:fs";
12686
- import { homedir as homedir5 } from "node:os";
12781
+ import { homedir as homedir6 } from "node:os";
12687
12782
  import { dirname as dirname6, isAbsolute as isAbsolute3, resolve as resolve3 } from "node:path";
12688
12783
  function sensitiveFilePathReason(resolvedPath) {
12689
- const home = homedir5();
12784
+ const home = homedir6();
12690
12785
  const sensitiveDirs = [
12691
12786
  { dir: resolve3(home, ".ssh"), label: "SSH keys" },
12692
12787
  { dir: resolve3(home, ".aws"), label: "AWS credentials" },
@@ -12749,7 +12844,7 @@ function substituteConfigVariables(input) {
12749
12844
  }
12750
12845
  let filePath = rawPath.trim();
12751
12846
  if (filePath.startsWith("~/")) {
12752
- filePath = resolve3(homedir5(), filePath.slice(2));
12847
+ filePath = resolve3(homedir6(), filePath.slice(2));
12753
12848
  } else if (!isAbsolute3(filePath)) {
12754
12849
  filePath = resolve3(configDir, filePath);
12755
12850
  }
@@ -16073,7 +16168,7 @@ import {
16073
16168
  statSync as statSync5,
16074
16169
  writeFileSync as writeFileSync4
16075
16170
  } from "node:fs";
16076
- import { homedir as homedir6, tmpdir as tmpdir2 } from "node:os";
16171
+ import { homedir as homedir7, tmpdir as tmpdir2 } from "node:os";
16077
16172
  import { dirname as dirname7, join as join5 } from "node:path";
16078
16173
  import { promisify } from "node:util";
16079
16174
  import { gunzipSync } from "node:zlib";
@@ -16554,7 +16649,7 @@ function defaultDashboardInstallDeps() {
16554
16649
  interactive: isInteractiveTerminal(process.stdin.isTTY, process.stdout.isTTY, process.env),
16555
16650
  platform: process.platform,
16556
16651
  arch: process.arch,
16557
- homeDir: homedir6(),
16652
+ homeDir: homedir7(),
16558
16653
  fetch: globalThis.fetch,
16559
16654
  releasesApiUrl: DASHBOARD_RELEASES_API,
16560
16655
  publicKey: DASHBOARD_UPDATER_PUBLIC_KEY,
@@ -16598,7 +16693,7 @@ var init_dashboard_install = __esm(() => {
16598
16693
  });
16599
16694
 
16600
16695
  // src/lib/cache-clear-path.ts
16601
- import { lstatSync as lstatSync3, realpathSync as realpathSync3 } from "node:fs";
16696
+ import { lstatSync as lstatSync3, realpathSync as realpathSync4 } from "node:fs";
16602
16697
  import { isAbsolute as isAbsolute4, join as join6, relative as relative2, resolve as resolve4, sep as sep2 } from "node:path";
16603
16698
  function descendantPath(root, path) {
16604
16699
  const child = relative2(root, path);
@@ -16623,7 +16718,7 @@ function checkCacheClearPath(cacheRoot, candidate) {
16623
16718
  if (!entry.isDirectory())
16624
16719
  return { allowed: false, reason: "unavailable", path: current };
16625
16720
  }
16626
- if (descendantPath(realpathSync3(root), realpathSync3(path)) === undefined) {
16721
+ if (descendantPath(realpathSync4(root), realpathSync4(path)) === undefined) {
16627
16722
  return { allowed: false, reason: "outside", path };
16628
16723
  }
16629
16724
  } catch (error) {
@@ -16683,16 +16778,16 @@ var init_find_on_path = () => {};
16683
16778
 
16684
16779
  // src/lib/paths.ts
16685
16780
  import { existsSync as existsSync9, lstatSync as lstatSync4, readdirSync as readdirSync2, statSync as statSync7 } from "node:fs";
16686
- import { homedir as homedir7 } from "node:os";
16781
+ import { homedir as homedir8 } from "node:os";
16687
16782
  import { delimiter as delimiter2, dirname as dirname8, join as join8, resolve as resolve5 } from "node:path";
16688
16783
  function getOpenCodeConfigDir() {
16689
16784
  const envDir = process.env.OPENCODE_CONFIG_DIR?.trim();
16690
16785
  if (envDir)
16691
16786
  return envDir;
16692
16787
  if (process.platform === "win32") {
16693
- return join8(homedir7(), ".config", "opencode");
16788
+ return join8(homedir8(), ".config", "opencode");
16694
16789
  }
16695
- const xdgConfig = process.env.XDG_CONFIG_HOME || join8(homedir7(), ".config");
16790
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join8(homedir8(), ".config");
16696
16791
  return join8(xdgConfig, "opencode");
16697
16792
  }
16698
16793
  function findOmoConfig(configDir) {
@@ -16750,7 +16845,7 @@ function detectConfigPaths() {
16750
16845
  }
16751
16846
  function envFirstHomeDir() {
16752
16847
  const home = process.env.HOME?.trim();
16753
- return home || homedir7();
16848
+ return home || homedir8();
16754
16849
  }
16755
16850
  function getPiAgentDir() {
16756
16851
  const envDir = process.env.PI_CODING_AGENT_DIR?.trim();
@@ -16855,7 +16950,7 @@ function getProjectHistorianDumpDir(directory) {
16855
16950
  return join8(getProjectMagicContextDir(directory), "historian");
16856
16951
  }
16857
16952
  function getOpenCodeCacheHome() {
16858
- return process.env.XDG_CACHE_HOME || join8(homedir7(), ".cache");
16953
+ return process.env.XDG_CACHE_HOME || join8(homedir8(), ".cache");
16859
16954
  }
16860
16955
  function getOpenCodePluginCacheDir() {
16861
16956
  return join8(getOpenCodeCacheHome(), "opencode", "packages");
@@ -16897,7 +16992,7 @@ var init_paths = __esm(() => {
16897
16992
 
16898
16993
  // src/lib/pi-helpers.ts
16899
16994
  import { execFileSync as execFileSync2, spawnSync } from "node:child_process";
16900
- import { homedir as homedir8 } from "node:os";
16995
+ import { homedir as homedir9 } from "node:os";
16901
16996
  import { extname, join as join9 } from "node:path";
16902
16997
  function getPiCommandInvocation(piPath, args) {
16903
16998
  const extension = extname(piPath).toLowerCase();
@@ -16911,7 +17006,7 @@ function detectPiBinary() {
16911
17006
  const fromPath = findOnPath("pi");
16912
17007
  if (fromPath)
16913
17008
  return { path: fromPath, source: "path" };
16914
- const home = process.env.HOME?.trim() || homedir8();
17009
+ const home = process.env.HOME?.trim() || homedir9();
16915
17010
  const homeCandidate = process.platform === "win32" ? join9(home, ".pi", "bin", "pi.cmd") : join9(home, ".pi", "bin", "pi");
16916
17011
  if (isExecutableFile(homeCandidate))
16917
17012
  return { path: homeCandidate, source: "home" };
@@ -16992,7 +17087,7 @@ var init_pi_helpers = __esm(() => {
16992
17087
  // src/lib/omp-helpers.ts
16993
17088
  import { spawnSync as spawnSync2 } from "node:child_process";
16994
17089
  import { existsSync as existsSync10, readFileSync as readFileSync8 } from "node:fs";
16995
- import { homedir as homedir9 } from "node:os";
17090
+ import { homedir as homedir10 } from "node:os";
16996
17091
  import { extname as extname2, join as join10 } from "node:path";
16997
17092
  function detectOmpPackageCli() {
16998
17093
  const packageDir = getOmpPackageDir();
@@ -17036,7 +17131,7 @@ function detectOmpBinary() {
17036
17131
  const fromPackage = detectOmpPackageCli();
17037
17132
  if (fromPackage)
17038
17133
  return { path: fromPackage, source: "package" };
17039
- const home = process.env.HOME?.trim() || homedir9();
17134
+ const home = process.env.HOME?.trim() || homedir10();
17040
17135
  const candidates = getOmpFallbackCandidates(process.platform, home, process.env.APPDATA);
17041
17136
  const candidate = candidates.find((path) => isExecutableFile(path));
17042
17137
  return candidate ? { path: candidate, source: "home" } : null;
@@ -17303,7 +17398,7 @@ var init_omp = __esm(() => {
17303
17398
 
17304
17399
  // ../plugin/src/shared/opencode-db-path.ts
17305
17400
  import { existsSync as existsSync11, readdirSync as readdirSync3, statSync as statSync8 } from "node:fs";
17306
- import { homedir as homedir10 } from "node:os";
17401
+ import { homedir as homedir11 } from "node:os";
17307
17402
  import { isAbsolute as isAbsolute5, join as join12, resolve as resolve6 } from "node:path";
17308
17403
  function openCodeHostGenerationFromVersion(version) {
17309
17404
  const text = version ?? "";
@@ -17313,7 +17408,7 @@ function openCodeHostGenerationFromVersion(version) {
17313
17408
  return Number.isFinite(major) && major >= 2 ? "v2" : "v1";
17314
17409
  }
17315
17410
  function openCodeDataDir(env = process.env, dataHome) {
17316
- return join12(dataHome ?? env.XDG_DATA_HOME ?? join12(homedir10(), ".local", "share"), "opencode");
17411
+ return join12(dataHome ?? env.XDG_DATA_HOME ?? join12(homedir11(), ".local", "share"), "opencode");
17317
17412
  }
17318
17413
  function environmentKey(dataDir, hostGeneration, channel, env) {
17319
17414
  return [
@@ -26128,15 +26223,15 @@ var init_jsonc_config = __esm(() => {
26128
26223
  });
26129
26224
 
26130
26225
  // src/lib/opencode-detect.ts
26131
- import { existsSync as existsSync15, realpathSync as realpathSync4 } from "node:fs";
26132
- import { homedir as homedir11 } from "node:os";
26226
+ import { existsSync as existsSync15, realpathSync as realpathSync5 } from "node:fs";
26227
+ import { homedir as homedir12 } from "node:os";
26133
26228
  import { join as join14 } from "node:path";
26134
26229
  function defaultDeps(overrides = {}) {
26135
26230
  const env = overrides.env ?? process.env;
26136
26231
  return {
26137
26232
  exists: overrides.exists ?? existsSync15,
26138
26233
  isExecutable: overrides.isExecutable ?? isExecutableFile,
26139
- home: overrides.home ?? (env.HOME?.trim() || homedir11()),
26234
+ home: overrides.home ?? (env.HOME?.trim() || homedir12()),
26140
26235
  platform: overrides.platform ?? process.platform,
26141
26236
  env,
26142
26237
  onPath: overrides.onPath ?? findOnPath,
@@ -26185,7 +26280,7 @@ function openChamberCliCandidates(d) {
26185
26280
  }
26186
26281
  function canonicalPath(d, path) {
26187
26282
  try {
26188
- return d.realpath ? d.realpath(path) : realpathSync4(path);
26283
+ return d.realpath ? d.realpath(path) : realpathSync5(path);
26189
26284
  } catch {
26190
26285
  return path;
26191
26286
  }
@@ -30079,7 +30174,7 @@ var init_project_identity_cache = __esm(() => {
30079
30174
  });
30080
30175
 
30081
30176
  // ../plugin/src/features/magic-context/memory/unborn-head.ts
30082
- import { readFileSync as readFileSync15, realpathSync as realpathSync5, statSync as statSync11 } from "node:fs";
30177
+ import { readFileSync as readFileSync15, realpathSync as realpathSync6, statSync as statSync11 } from "node:fs";
30083
30178
  import path5 from "node:path";
30084
30179
  function errorCode(error) {
30085
30180
  if (error === null || typeof error !== "object" || !("code" in error))
@@ -30221,7 +30316,7 @@ function isUnbornHeadOnDisk(directory, env = process.env) {
30221
30316
  }
30222
30317
  let realDirectory;
30223
30318
  try {
30224
- realDirectory = realpathSync5.native(path5.resolve(directory));
30319
+ realDirectory = realpathSync6.native(path5.resolve(directory));
30225
30320
  } catch {
30226
30321
  return false;
30227
30322
  }
@@ -30240,8 +30335,8 @@ var init_unborn_head = __esm(() => {
30240
30335
  // ../plugin/src/features/magic-context/memory/project-identity.ts
30241
30336
  import { execFileSync as execFileSync4 } from "node:child_process";
30242
30337
  import { createHash as createHash5 } from "node:crypto";
30243
- import { existsSync as existsSync19, realpathSync as realpathSync6, statSync as statSync12 } from "node:fs";
30244
- import { homedir as homedir12 } from "node:os";
30338
+ import { existsSync as existsSync19, realpathSync as realpathSync7, statSync as statSync12 } from "node:fs";
30339
+ import { homedir as homedir13 } from "node:os";
30245
30340
  import path6 from "node:path";
30246
30341
  function asError(error) {
30247
30342
  return error instanceof Error ? error : undefined;
@@ -30437,7 +30532,7 @@ function nearestLastKnownGitIdentity(canonical) {
30437
30532
  if (exactOrAncestor)
30438
30533
  return exactOrAncestor;
30439
30534
  try {
30440
- const realCanonical = realpathSync6.native(canonical);
30535
+ const realCanonical = realpathSync7.native(canonical);
30441
30536
  if (realCanonical !== canonical)
30442
30537
  return walk(realCanonical);
30443
30538
  } catch {}
@@ -30467,7 +30562,7 @@ function recordDubiousOwnershipFallback(canonical) {
30467
30562
  function canonicalUserHomeDirectory() {
30468
30563
  const homeDirectory = userHomeDirectoryForIdentity();
30469
30564
  try {
30470
- return realpathSync6.native(homeDirectory);
30565
+ return realpathSync7.native(homeDirectory);
30471
30566
  } catch {
30472
30567
  return homeDirectory;
30473
30568
  }
@@ -30476,7 +30571,7 @@ function isUserHomeDirectory(directory) {
30476
30571
  if (projectDirectoryKey(directory) === projectDirectoryKey(userHomeDirectoryForIdentity()))
30477
30572
  return true;
30478
30573
  try {
30479
- return projectDirectoryKey(realpathSync6.native(path6.resolve(directory))) === projectDirectoryKey(canonicalUserHomeDirectory());
30574
+ return projectDirectoryKey(realpathSync7.native(path6.resolve(directory))) === projectDirectoryKey(canonicalUserHomeDirectory());
30480
30575
  } catch {
30481
30576
  return false;
30482
30577
  }
@@ -30538,7 +30633,7 @@ function hasGitDir(canonical) {
30538
30633
  return true;
30539
30634
  }
30540
30635
  try {
30541
- const realCanonical = realpathSync6.native(canonical);
30636
+ const realCanonical = realpathSync7.native(canonical);
30542
30637
  return realCanonical !== canonical && hasGitDirInAncestorChain(realCanonical);
30543
30638
  } catch {
30544
30639
  return false;
@@ -30549,7 +30644,7 @@ function gitRootInAncestorChain(startDirectory) {
30549
30644
  while (true) {
30550
30645
  if (existsSync19(path6.join(current, ".git"))) {
30551
30646
  try {
30552
- return realpathSync6.native(current);
30647
+ return realpathSync7.native(current);
30553
30648
  } catch {
30554
30649
  return path6.resolve(current);
30555
30650
  }
@@ -30569,13 +30664,13 @@ function gitRootDirectory(canonical) {
30569
30664
  if (direct)
30570
30665
  return direct;
30571
30666
  try {
30572
- const realCanonical = realpathSync6.native(canonical);
30667
+ const realCanonical = realpathSync7.native(canonical);
30573
30668
  return realCanonical === canonical ? null : gitRootInAncestorChain(realCanonical);
30574
30669
  } catch {
30575
30670
  return null;
30576
30671
  }
30577
30672
  }
30578
- var GIT_TIMEOUT_MS = 5000, TRANSIENT_FAILURE_COOLDOWN_MS, identityCache, linkedGitWorktreeCache, lastKnownGitIdentityCache, directoryFallbackCache, transientFailureCooldown, dubiousOwnershipFallbackDirectories, dubiousOwnershipLoggedDirectories, dubiousOwnershipWarnedDirectories, transientGitIdentityReuseLoggedDirectories, sessionIdentityCache, homeProjectPermission = false, pausedIdentityReasons, pausedIdentityLogged, execFileSyncForIdentity, gitTimeoutMs, userHomeDirectoryForIdentity = () => homedir12(), nowMs = () => Date.now(), ProjectIdentityError;
30673
+ var GIT_TIMEOUT_MS = 5000, TRANSIENT_FAILURE_COOLDOWN_MS, identityCache, linkedGitWorktreeCache, lastKnownGitIdentityCache, directoryFallbackCache, transientFailureCooldown, dubiousOwnershipFallbackDirectories, dubiousOwnershipLoggedDirectories, dubiousOwnershipWarnedDirectories, transientGitIdentityReuseLoggedDirectories, sessionIdentityCache, homeProjectPermission = false, pausedIdentityReasons, pausedIdentityLogged, execFileSyncForIdentity, gitTimeoutMs, userHomeDirectoryForIdentity = () => homedir13(), nowMs = () => Date.now(), ProjectIdentityError;
30579
30674
  var init_project_identity = __esm(() => {
30580
30675
  init_logger();
30581
30676
  init_project_identity_cache();
@@ -37013,6 +37108,7 @@ var init_message_time_backfill = __esm(async () => {
37013
37108
  // ../plugin/src/features/magic-context/storage-db.ts
37014
37109
  import {
37015
37110
  existsSync as existsSync21,
37111
+ lstatSync as lstatSync6,
37016
37112
  readdirSync as readdirSync5,
37017
37113
  readFileSync as readFileSync16,
37018
37114
  rmdirSync as rmdirSync2,
@@ -37020,11 +37116,73 @@ import {
37020
37116
  unlinkSync as unlinkSync4
37021
37117
  } from "node:fs";
37022
37118
  import { basename as basename5, dirname as dirname12, join as join16, resolve as resolve9 } from "node:path";
37023
- function ensureSecureStorageDir(dir) {
37024
- ensureStorageDirectorySync(dir);
37119
+ function isLinkedStorageRoot(dir) {
37120
+ if (process.platform === "win32")
37121
+ return false;
37122
+ try {
37123
+ return lstatSync6(dir).isSymbolicLink();
37124
+ } catch {
37125
+ return false;
37126
+ }
37127
+ }
37128
+ function ensureSecureStorageDir(dir, dbPath) {
37129
+ try {
37130
+ ensureStorageDirectorySync(dir);
37131
+ } catch (error) {
37132
+ if (shouldEnforcePrivateStoragePermissions() && isLinkedStorageRoot(dir)) {
37133
+ tightenStorageTree(dbPath, true);
37134
+ }
37135
+ throw error;
37136
+ }
37137
+ }
37138
+ function describeLinkedStorageSkip(reason) {
37139
+ switch (reason) {
37140
+ case "filesystem-root":
37141
+ return "it is a filesystem root";
37142
+ case "home-folder":
37143
+ return "it is your home folder";
37144
+ case "mount-point":
37145
+ return "it is a mount point";
37146
+ default: {
37147
+ const entries = reason === 1 ? "entry" : "entries";
37148
+ return `it holds ${reason} ${entries} that Magic Context did not create`;
37149
+ }
37150
+ }
37151
+ }
37152
+ function describeLinkedStorageFailure(failure, nonDirectoryPath) {
37153
+ if (nonDirectoryPath !== undefined)
37154
+ return `${nonDirectoryPath} is not a directory`;
37155
+ switch (failure) {
37156
+ case "ENOENT":
37157
+ return "ENOENT";
37158
+ case "ELOOP":
37159
+ return "ELOOP";
37160
+ case "EACCES":
37161
+ return "EACCES";
37162
+ case "EPERM":
37163
+ return "EPERM";
37164
+ case "ENOTDIR":
37165
+ return "ENOTDIR";
37166
+ default:
37167
+ return "could not resolve or inspect the linked target";
37168
+ }
37025
37169
  }
37026
- function tightenStorageTree(dbPath) {
37027
- const { failures } = tightenStorageTreeSync(dirname12(dbPath), dbPath);
37170
+ function tightenStorageTree(dbPath, reportResolvedLink = false) {
37171
+ const { failures, rootLink } = tightenStorageTreeSync(dirname12(dbPath), dbPath);
37172
+ if (rootLink && "failure" in rootLink) {
37173
+ log(`[magic-context] storage permission tightening failures=${failures}: storage root link ${rootLink.path}: ${describeLinkedStorageFailure(rootLink.failure, rootLink.nonDirectoryTarget)}`);
37174
+ return;
37175
+ }
37176
+ if (rootLink?.skipped !== undefined) {
37177
+ if (reportResolvedLink) {
37178
+ const { path: linkPath, target: targetPath } = rootLink;
37179
+ log(`[magic-context] linked storage folder ${linkPath} -> ${targetPath} was not made private because ${describeLinkedStorageSkip(rootLink.skipped)}. Move the store to a folder of its own so Magic Context can protect it.`);
37180
+ }
37181
+ return;
37182
+ }
37183
+ if (rootLink && reportResolvedLink) {
37184
+ log(`[magic-context] resolved storage root link ${rootLink.path} -> ${rootLink.target}`);
37185
+ }
37028
37186
  log(`[magic-context] storage permission tightening failures=${failures}`);
37029
37187
  }
37030
37188
  function resolveBootBusyTimeoutMs(value) {
@@ -37053,7 +37211,7 @@ function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
37053
37211
  if (!existsSync21(legacyDbPath))
37054
37212
  return;
37055
37213
  log(`[magic-context] migrating legacy plugin storage: ${legacyDir} -> ${targetDbDir} (legacy left in place as backup)`);
37056
- ensureSecureStorageDir(targetDbDir);
37214
+ ensureSecureStorageDir(targetDbDir, targetDbPath);
37057
37215
  try {
37058
37216
  const legacyDb = new Database(legacyDbPath);
37059
37217
  try {
@@ -38807,8 +38965,8 @@ function openDatabase(dbPathOrOptions) {
38807
38965
  if (!explicitDbPath) {
38808
38966
  migrateLegacyStorageIfNeeded(dbPath, dbDir);
38809
38967
  }
38810
- ensureSecureStorageDir(dbDir);
38811
- tightenStorageTree(dbPath);
38968
+ ensureSecureStorageDir(dbDir, dbPath);
38969
+ tightenStorageTree(dbPath, true);
38812
38970
  if (!existsSync21(dbPath) && shouldEnforcePrivateStoragePermissions()) {
38813
38971
  try {
38814
38972
  writeStorageFileSync(dbPath, new Uint8Array, { flag: "wx" });
@@ -39762,10 +39920,10 @@ var init_setup_omp = __esm(() => {
39762
39920
  });
39763
39921
 
39764
39922
  // ../plugin/src/shared/opencode-config-dir.ts
39765
- import { homedir as homedir13 } from "node:os";
39923
+ import { homedir as homedir14 } from "node:os";
39766
39924
  import { join as join17, resolve as resolve10 } from "node:path";
39767
39925
  function resolveHomeDir() {
39768
- return process.env.HOME?.trim() || homedir13();
39926
+ return process.env.HOME?.trim() || homedir14();
39769
39927
  }
39770
39928
  function getOpenCodeGlobalConfigDir() {
39771
39929
  if (process.platform === "win32") {
@@ -39804,7 +39962,7 @@ var init_opencode_config_dir = () => {};
39804
39962
 
39805
39963
  // ../plugin/src/shared/conflict-detector.ts
39806
39964
  import { readFileSync as readFileSync17 } from "node:fs";
39807
- import { homedir as homedir14 } from "node:os";
39965
+ import { homedir as homedir15 } from "node:os";
39808
39966
  import { join as join18 } from "node:path";
39809
39967
  function detectConflicts(directory, options) {
39810
39968
  const compactionEnabled = options?.compactionEnabled ?? true;
@@ -40062,7 +40220,7 @@ function readOmoDisabledHooks(directory) {
40062
40220
  }
40063
40221
  }
40064
40222
  }
40065
- const homeDir = process.env.HOME || homedir14();
40223
+ const homeDir = process.env.HOME || homedir15();
40066
40224
  const omoHomeDir = join18(homeDir, ".omo");
40067
40225
  for (const name of ["omo.jsonc", "omo.json"]) {
40068
40226
  const config = readJsoncFile(join18(omoHomeDir, name));
@@ -40093,7 +40251,7 @@ var init_conflict_detector = __esm(() => {
40093
40251
 
40094
40252
  // ../plugin/src/shared/conflict-fixer.ts
40095
40253
  import { existsSync as existsSync24, readFileSync as readFileSync18, writeFileSync as writeFileSync6 } from "node:fs";
40096
- import { homedir as homedir15 } from "node:os";
40254
+ import { homedir as homedir16 } from "node:os";
40097
40255
  import { join as join19 } from "node:path";
40098
40256
  function isRecord3(value) {
40099
40257
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -40156,7 +40314,7 @@ function collectOmoConfigPaths(directory) {
40156
40314
  paths.add(projectPath);
40157
40315
  }
40158
40316
  }
40159
- const homeDir = process.env.HOME || homedir15();
40317
+ const homeDir = process.env.HOME || homedir16();
40160
40318
  const omoHomeDir = join19(homeDir, ".omo");
40161
40319
  for (const name of OMO_UNIFIED_NAMES) {
40162
40320
  const userPath = join19(omoHomeDir, name);
@@ -40811,19 +40969,19 @@ function existingDirectoryAncestor(path) {
40811
40969
  var init_disk_space = () => {};
40812
40970
 
40813
40971
  // ../plugin/src/hooks/auto-update-checker/constants.ts
40814
- import { homedir as homedir16, platform } from "node:os";
40972
+ import { homedir as homedir17, platform } from "node:os";
40815
40973
  import { join as join20 } from "node:path";
40816
40974
  function getOpenCodeCacheRoot() {
40817
40975
  if (platform() === "win32") {
40818
- return join20(process.env.LOCALAPPDATA ?? homedir16(), "opencode");
40976
+ return join20(process.env.LOCALAPPDATA ?? homedir17(), "opencode");
40819
40977
  }
40820
- return join20(homedir16(), ".cache", "opencode");
40978
+ return join20(homedir17(), ".cache", "opencode");
40821
40979
  }
40822
40980
  function getOpenCodeConfigRoot() {
40823
40981
  if (platform() === "win32") {
40824
- return join20(process.env.APPDATA ?? join20(homedir16(), "AppData", "Roaming"), "opencode");
40982
+ return join20(process.env.APPDATA ?? join20(homedir17(), "AppData", "Roaming"), "opencode");
40825
40983
  }
40826
- return join20(process.env.XDG_CONFIG_HOME ?? join20(homedir16(), ".config"), "opencode");
40984
+ return join20(process.env.XDG_CONFIG_HOME ?? join20(homedir17(), ".config"), "opencode");
40827
40985
  }
40828
40986
  var PACKAGE_NAME = "@cortexkit/opencode-magic-context", CACHE_DIR, USER_OPENCODE_CONFIG, USER_OPENCODE_CONFIG_JSONC;
40829
40987
  var init_constants2 = __esm(() => {
@@ -41529,11 +41687,11 @@ var init_doctor_prune_discovery = __esm(async () => {
41529
41687
 
41530
41688
  // src/commands/doctor-storage-holders.ts
41531
41689
  import { execFileSync as execFileSync5 } from "node:child_process";
41532
- import { readFileSync as readFileSync22, realpathSync as realpathSync7 } from "node:fs";
41690
+ import { readFileSync as readFileSync22, realpathSync as realpathSync8 } from "node:fs";
41533
41691
  import { join as join23, resolve as resolve13 } from "node:path";
41534
41692
  function canonicalStoragePath(path) {
41535
41693
  try {
41536
- return realpathSync7(path);
41694
+ return realpathSync8(path);
41537
41695
  } catch {
41538
41696
  return resolve13(path);
41539
41697
  }
@@ -41580,11 +41738,11 @@ var init_doctor_storage_holders = () => {};
41580
41738
  // src/commands/doctor-repair-db.ts
41581
41739
  import { spawnSync as spawnSync4 } from "node:child_process";
41582
41740
  import { closeSync as closeSync4, existsSync as existsSync31, openSync as openSync4, renameSync as renameSync6, rmSync as rmSync8, statSync as statSync16 } from "node:fs";
41583
- import { homedir as homedir17 } from "node:os";
41741
+ import { homedir as homedir18 } from "node:os";
41584
41742
  import { dirname as dirname19, join as join24 } from "node:path";
41585
41743
  function defaultInspectHolders(storageDir, overrides = {}) {
41586
41744
  const deps = {
41587
- defaultStorageDir: join24(homedir17(), ".local", "share", "cortexkit", "magic-context"),
41745
+ defaultStorageDir: join24(homedir18(), ".local", "share", "cortexkit", "magic-context"),
41588
41746
  inspectRpc: inspectRpcServerDiscovery,
41589
41747
  inspectPi: inspectLivePiProcesses,
41590
41748
  probeFiles: probeHostProcessesUsing,
@@ -42153,7 +42311,7 @@ var init_doctor_repair_db = __esm(async () => {
42153
42311
  // src/commands/doctor-single-store-repair.ts
42154
42312
  import { spawnSync as spawnSync5 } from "node:child_process";
42155
42313
  import { existsSync as existsSync32, statfsSync as statfsSync2, statSync as statSync17 } from "node:fs";
42156
- import { homedir as homedir18 } from "node:os";
42314
+ import { homedir as homedir19 } from "node:os";
42157
42315
  import { dirname as dirname20, join as join25, resolve as resolve14 } from "node:path";
42158
42316
  function existingAncestor(path) {
42159
42317
  let current = resolve14(path);
@@ -42237,7 +42395,7 @@ function runDoctorSingleStoreRepair(options, overrides = {}) {
42237
42395
  backupDir = join25(backupRoot, `repair-history-${deps.now().toISOString().replaceAll(":", "-")}`);
42238
42396
  deps.print(`Backing up the live stores to ${backupDir} before any write.`);
42239
42397
  }
42240
- const binary = options.ckMc ?? join25(homedir18(), ".local", "share", "cortexkit", "bin", "ck-mc");
42398
+ const binary = options.ckMc ?? join25(homedir19(), ".local", "share", "cortexkit", "bin", "ck-mc");
42241
42399
  const args = [
42242
42400
  "single-store-repair-history",
42243
42401
  "--context-db",
@@ -42325,8 +42483,8 @@ var init_doctor_single_store_repair = __esm(async () => {
42325
42483
 
42326
42484
  // src/commands/doctor-single-store.ts
42327
42485
  import { spawnSync as spawnSync6 } from "node:child_process";
42328
- import { existsSync as existsSync33, realpathSync as realpathSync8, statSync as statSync18 } from "node:fs";
42329
- import { homedir as homedir19 } from "node:os";
42486
+ import { existsSync as existsSync33, realpathSync as realpathSync9, statSync as statSync18 } from "node:fs";
42487
+ import { homedir as homedir20 } from "node:os";
42330
42488
  import { join as join26, resolve as resolve15 } from "node:path";
42331
42489
  function engineContextPath() {
42332
42490
  const value = (key) => process.env[key]?.trim() || undefined;
@@ -42374,7 +42532,7 @@ function runDoctorSingleStore(options = {}, overrides = {}) {
42374
42532
  return refuse("single_store_files_in_use", [...lines, STOP].join(`
42375
42533
  `));
42376
42534
  }
42377
- if (!existsSync33(engineContextPath()) || realpathSync8(context) !== realpathSync8(engineContextPath()))
42535
+ if (!existsSync33(engineContextPath()) || realpathSync9(context) !== realpathSync9(engineContextPath()))
42378
42536
  return refuse("single_store_path_mismatch", `CLI ${context}; engine ${engineContextPath()}`);
42379
42537
  const backupRoot = resolve15(options.backupRoot ?? join26(data, "backups"));
42380
42538
  const contextDb = openExistingDatabase(context, { readonly: true });
@@ -42430,7 +42588,7 @@ function runDoctorSingleStore(options = {}, overrides = {}) {
42430
42588
  }
42431
42589
  if (contextVersion !== LATEST_SUPPORTED_VERSION)
42432
42590
  return refuse("single_store_version_mismatch", `context.db v${contextVersion}; store.db v${storeVersion}`);
42433
- const binary = options.ckMc ?? join26(homedir19(), ".local", "share", "cortexkit", "bin", "ck-mc");
42591
+ const binary = options.ckMc ?? join26(homedir20(), ".local", "share", "cortexkit", "bin", "ck-mc");
42434
42592
  const args = [
42435
42593
  "single-store-migrate",
42436
42594
  "--context-db",
@@ -42933,7 +43091,7 @@ var IDENTITY_MERGE_COMMAND = "npx @cortexkit/magic-context@latest doctor merge-i
42933
43091
  // src/commands/doctor-identity-splits.ts
42934
43092
  import { execFileSync as execFileSync6 } from "node:child_process";
42935
43093
  import { createHash as createHash6 } from "node:crypto";
42936
- import { existsSync as existsSync34, readdirSync as readdirSync7, realpathSync as realpathSync9, statSync as statSync19 } from "node:fs";
43094
+ import { existsSync as existsSync34, readdirSync as readdirSync7, realpathSync as realpathSync10, statSync as statSync19 } from "node:fs";
42937
43095
  import { dirname as dirname21, isAbsolute as isAbsolute9, join as join27, resolve as resolve16 } from "node:path";
42938
43096
  function tableExists5(db, table) {
42939
43097
  return !!db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table);
@@ -43007,7 +43165,7 @@ function findIdentitySplits(db, host, includeSingles = false) {
43007
43165
  return cached;
43008
43166
  let canonical = directory;
43009
43167
  try {
43010
- canonical = realpathSync9.native(directory);
43168
+ canonical = realpathSync10.native(directory);
43011
43169
  } catch {}
43012
43170
  canonicalDirectories.set(directory, canonical);
43013
43171
  return canonical;
@@ -46824,7 +46982,7 @@ var init_store_ahead_refusal = __esm(() => {
46824
46982
  });
46825
46983
 
46826
46984
  // ../plugin/src/hooks/magic-context/module-transport.ts
46827
- import { realpathSync as realpathSync10 } from "node:fs";
46985
+ import { realpathSync as realpathSync11 } from "node:fs";
46828
46986
  import { join as join31 } from "node:path";
46829
46987
  function monotonicNow() {
46830
46988
  return monotonicClockForTests?.() ?? performance.now();
@@ -47326,7 +47484,7 @@ class SubcModuleTransport {
47326
47484
  }
47327
47485
  let resolved = root;
47328
47486
  try {
47329
- resolved = realpathSync10.native(root);
47487
+ resolved = realpathSync11.native(root);
47330
47488
  } catch {}
47331
47489
  this.canonicalRootCache.set(root, resolved);
47332
47490
  while (this.canonicalRootCache.size > CANONICAL_ROOT_CACHE_MAX_ENTRIES) {
@@ -47439,8 +47597,8 @@ var init_module_transport = __esm(async () => {
47439
47597
  });
47440
47598
 
47441
47599
  // src/commands/migrate-session.ts
47442
- import { existsSync as existsSync38, realpathSync as realpathSync11 } from "node:fs";
47443
- import { homedir as homedir20 } from "node:os";
47600
+ import { existsSync as existsSync38, realpathSync as realpathSync12 } from "node:fs";
47601
+ import { homedir as homedir21 } from "node:os";
47444
47602
  import path7, { join as join32 } from "node:path";
47445
47603
  function existingSessionColumns(db) {
47446
47604
  const rows = db.prepare("PRAGMA table_info(session)").all();
@@ -47630,7 +47788,7 @@ function realDeps(opencodeDb, contextDb) {
47630
47788
  contextDb,
47631
47789
  resolveIdentity: resolveProjectIdentity,
47632
47790
  hasGitDir: (dir) => existsSync38(join32(dir, ".git")),
47633
- realpath: (p) => realpathSync11(p)
47791
+ realpath: (p) => realpathSync12(p)
47634
47792
  };
47635
47793
  }
47636
47794
  function valueAfter(args, flag) {
@@ -47707,7 +47865,7 @@ async function runMigrateSessionCli(args) {
47707
47865
  printMigrateSessionHelp();
47708
47866
  return 1;
47709
47867
  }
47710
- const expandedTo = toDir.startsWith("~") ? join32(homedir20(), toDir.slice(1).replace(/^[/\\]/, "")) : toDir;
47868
+ const expandedTo = toDir.startsWith("~") ? join32(homedir21(), toDir.slice(1).replace(/^[/\\]/, "")) : toDir;
47711
47869
  if (!existsSync38(expandedTo)) {
47712
47870
  console.error(`Target directory does not exist: ${expandedTo}`);
47713
47871
  return 1;
@@ -47862,7 +48020,7 @@ var init_migrate_session = __esm(async () => {
47862
48020
 
47863
48021
  // ../plugin/src/features/magic-context/v22-deferred-backfill.ts
47864
48022
  import { createHash as createHash10 } from "node:crypto";
47865
- import { realpathSync as realpathSync12 } from "node:fs";
48023
+ import { realpathSync as realpathSync13 } from "node:fs";
47866
48024
  import path8 from "node:path";
47867
48025
  function readMeta(db, key) {
47868
48026
  const row = db.prepare("SELECT value FROM schema_migrations_meta WHERE key = ?").get(key);
@@ -47906,7 +48064,7 @@ function resolveBackfillIdentity(rawProjectPath) {
47906
48064
  function computeLegacyRustDirIdentity(rawProjectPath) {
47907
48065
  let canonical;
47908
48066
  try {
47909
- canonical = realpathSync12(rawProjectPath);
48067
+ canonical = realpathSync13(rawProjectPath);
47910
48068
  } catch {
47911
48069
  canonical = path8.isAbsolute(rawProjectPath) ? rawProjectPath : path8.join(process.cwd(), rawProjectPath);
47912
48070
  }
@@ -48810,9 +48968,11 @@ var init_issue_log_templates_generated = __esm(() => {
48810
48968
  "[magic-context] storage warning: continuing migration for \x01; Pi/OMP PID \x01 was not confirmed as a live harness because the process image or command line was ambiguous. No live Pi harness was confirmed.\x020p",
48811
48969
  "[shadow] backfill scope \x01 for \x01 retired without progress — the selected source rows changed before the writer loaded them; \x01+ items remain and automatic registration will not retry unchanged candidates",
48812
48970
  "[shadow] backfill scope \x01 for \x01 retired without progress — the write completed without satisfying the selected candidate; \x01+ items remain and automatic registration will not retry unchanged candidates",
48971
+ "[magic-context] linked storage folder \x01 -> \x01 was not made private because it holds \x01 entries that Magic Context did not create. Move the store to a folder of its own so Magic Context can protect it.\x020p,1p",
48813
48972
  "served check: a change in front of kept signed thinking on a prefix-bound model first_index=\x01 kept_thinking_index=\x01 recorded_thinking_index=\x01 thinking_stripped=\x01 kind=replay permitted=\x01 seen_by=\x01 host=\x01",
48814
48973
  "transform: unknown provider usage; using wire estimate for priced pass inputTokens=\x01 percentage=\x01 trusted=\x01 wireTokens=\x01 pressureTokens=\x01 grewPastSavedReading=\x01 sizedPlan=clears_reasoning+covered_rows",
48815
48974
  "served check: a change in front of kept signed thinking on a prefix-bound model first_index=\x01 kept_thinking_index=\x01 recorded_thinking_index=\x01 thinking_stripped=\x01 kind=input permitted=\x01 seen_by=\x01 host=\x01",
48975
+ "[magic-context] linked storage folder \x01 -> \x01 was not made private because it holds \x01 entry that Magic Context did not create. Move the store to a folder of its own so Magic Context can protect it.\x020p,1p",
48816
48976
  "transform: unknown provider usage; using wire estimate for priced pass inputTokens=\x01 percentage=\x01 trusted=\x01 wireTokens=\x01 pressureTokens=\x01 grewPastSavedReading=\x01 sizedPlan=keeps_reasoning+covered_rows",
48817
48977
  "served check: a change in front of kept signed thinking on a prefix-bound model first_index=\x01 kept_thinking_index=\x01 recorded_thinking_index=\x01 thinking_stripped=\x01 kind=pass permitted=\x01 seen_by=\x01 host=\x01",
48818
48978
  "[magic-context] openai-compatible embedding rate limited (HTTP 429): pausing requests for \x01s (Retry-After); background embedding resumes after the pause and searches run lexical-only until then",
@@ -48855,13 +49015,18 @@ var init_issue_log_templates_generated = __esm(() => {
48855
49015
  "[pi-subagent] registered tools: ctx_search, ctx_memory, todowrite (ctx_note/ctx_expand omitted: --no-session child; memory=\x01, embedding=\x01, git_commits=\x01, dreamer_actions=\x01)",
48856
49016
  "transform: recovery for an uncut history already ran on this exact state and made no room; idle until the conversation, its summaries or its dropped tool output change",
48857
49017
  "transform: recovery request not counted: the fit envelope is untrusted (system prompt or tool definitions not measured yet), so only the byte-count check above applies",
49018
+ "[magic-context] linked storage folder \x01 -> \x01 was not made private because it is a filesystem root. Move the store to a folder of its own so Magic Context can protect it.\x020p,1p",
48858
49019
  "transform: unknown provider usage; using provider-proven input for priced pass inputTokens=\x01 percentage=\x01 trusted=\x01 wireTokens=\x01 pressureTokens=\x01 sizedPlan=clears_reasoning",
48859
49020
  "[magic-context] conflict-detector: no OpenCode config file carried an explicit compaction block; treating native compaction as inconclusive (not disabling the plugin)",
49021
+ "[magic-context] linked storage folder \x01 -> \x01 was not made private because it is your home folder. Move the store to a folder of its own so Magic Context can protect it.\x020p,1p",
49022
+ "v2 host fold: after history recovery, the native record for checkpoint \x01 was re-admitted; \x01 covered instruction rows are no longer sent, changing the cached prefix once",
48860
49023
  "historian redundancy skip: summarizer not needed this pass — force band is \x01%; queued/automatic drops are projected to reclaim to \x01% (target \x01%) on this pass (ride=none)",
48861
49024
  "transform: unknown provider usage; using provider-proven input for priced pass inputTokens=\x01 percentage=\x01 trusted=\x01 wireTokens=\x01 pressureTokens=\x01 sizedPlan=keeps_reasoning",
48862
49025
  "Pi content-decision ledger unreadable: tag identity duplicates are served unmerged and no stored decision is replayed or written; the stored field is left untouched: \x01",
48863
49026
  "compaction-marker drain: marker unchanged (reason=left-unchanged); serving rebuilt history and keeping the pending marker for the next pass with rewrite permission: \x01",
48864
49027
  "compaction-marker drain: marker unchanged (reason=left-unchanged); serving rebuilt history and keeping the pending marker for the next pass with rewrite permission:",
49028
+ "v2 host fold: after history recovery, the native record for checkpoint \x01 was re-admitted; \x01 covered instruction row is no longer sent, changing the cached prefix once",
49029
+ "[magic-context] linked storage folder \x01 -> \x01 was not made private because it is a mount point. Move the store to a folder of its own so Magic Context can protect it.\x020p,1p",
48865
49030
  "[magic-context] Magic Context storage is at \x01, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.\x020p",
48866
49031
  "[magic-context] Magic Context storage is at \x01, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.",
48867
49032
  "provider_usage_not_single_request: message_end input \x01 exceeds pressure evidence bound \x01; ignoring possible turn-aggregate billing usage and using request estimates",
@@ -48880,6 +49045,7 @@ var init_issue_log_templates_generated = __esm(() => {
48880
49045
  "OMP dispatch fence disabled for session \x01: verified ephemeral context; session-wide abort cannot distinguish provider operations (side_contexts=\x01 context_passes=\x01)",
48881
49046
  'historian failure: source=no-progress reason="historian returned compartments that did not advance past raw message \x01" newCompartmentCount=\x01 lastNewEnd=\x01 priorEnd=\x01',
48882
49047
  "transform: unknown provider usage; using wire estimate for priced pass inputTokens=\x01 percentage=\x01 trusted=\x01 wireTokens=\x01 pressureTokens=\x01 sizedPlan=clears_reasoning",
49048
+ "over-window first pass not sent: the request is still about \x01 tokens after this pass (tool definitions: \x01), over the \x01-token window (history started at \x01) (MC-H06)",
48883
49049
  "[magic-context] git identity resolution is temporarily unavailable for \x01; reusing the last successful project identity to avoid splitting project-scoped memory\x020p",
48884
49050
  "[magic-context] git identity resolution is temporarily unavailable for \x01; reusing the last successful project identity to avoid splitting project-scoped memory",
48885
49051
  "transform: unknown provider usage; using wire estimate for priced pass inputTokens=\x01 percentage=\x01 trusted=\x01 wireTokens=\x01 pressureTokens=\x01 sizedPlan=keeps_reasoning",
@@ -48953,7 +49119,6 @@ var init_issue_log_templates_generated = __esm(() => {
48953
49119
  "[magic-context] compaction-marker: deferred candidate preparation for \x01: summary set or frontier changed during discovery; marker unchanged\x020s",
48954
49120
  "[magic-context] [ERROR] compaction-marker: candidate worker unavailable \x01: worker deadline exceeded; marker unchanged, advancement deferred\x020p",
48955
49121
  "[magic-context] [ERROR] compaction-marker: candidate worker unavailable \x01: worker deadline exceeded; marker unchanged, advancement deferred",
48956
- "over-window first pass not sent: the request is still about \x01 tokens after this pass, over the \x01-token window (history started at \x01) (MC-H06)",
48957
49122
  "m[0]/m[1] frozen: active thinking turn in compaction-off mode (prefix-bound model); replaying the frozen prefix and deferring any rebuild",
48958
49123
  "rust prefix-bust permission unsupported: upgrade ck-mc to a build emitting boolean prefix_bust_permitted; holding host first applications",
48959
49124
  "transform produced an assistant-terminated request (input was user-terminated); providers without prefill support will reject it. tail=[\x01]",
@@ -49005,6 +49170,7 @@ var init_issue_log_templates_generated = __esm(() => {
49005
49170
  "clone-inheritance: failed source=unknown dest=unknown stage=resolve-destination error=\x01; run /ctx-wrapup to rebuild, or re-clone",
49006
49171
  "[magic-context] conflict-detector: resolved config carried no explicit compaction.auto (\x01); falling back to file-based detection",
49007
49172
  "[magic-context] sqlite writer site=compaction-marker-inject db=opencode acquire_ms=\x01 hold_ms=\x01 work_ms=\x01 end_ms=\x01 outcome=committed",
49173
+ "over-window first pass reduced: the request is about \x01 tokens (tool definitions: \x01; history started at \x01), under the \x01-token window",
49008
49174
  "auto-search: decision outcome=below-threshold reason=\x01 lanes=\x01 nearMisses=\x01 threshold=\x01 pool=\x01 rows=\x01 workerStarted=\x01 peek=\x01 elapsedMs=\x01",
49009
49175
  "[magic-context] registered historian trigger: DISABLED (configure the active harness's historian model in magic-context.jsonc)",
49010
49176
  "historian start released after \x01 passes waiting for an exact ordinal read; a later pass starts it again once that read finishes",
@@ -49039,6 +49205,7 @@ var init_issue_log_templates_generated = __esm(() => {
49039
49205
  "mc-module: render identity session=\x01 changed=\x01 observed=\x01 coordinator=\x01 transition=\x01 tool_present=\x01 profile=\x01 effective=\x01 persisted=\x01",
49040
49206
  "latest-turn thinking recovery: restore no longer possible (missing-thinking-original); removing the turn's thinking instead",
49041
49207
  "[mural] rendered for \x01: \x01 cues drawn, \x01 left out for space, \x01 left out because the mural font has no glyph for their characters",
49208
+ "[magic-context] storage permission tightening failures=\x01: storage root link \x01: could not resolve or inspect the linked target\x021p",
49042
49209
  "[dreamer] retrospective: watermark start=\x01 maxScannedTs=\x01 patch=\x01 stored=\x01 usableInputTokens=\x01 recencyCutoffMs=\x01 budgetTruncated=\x01",
49043
49210
  "compartment trigger: force-firing at \x01% (projected post-drop \x01%) admittedBy=overflow_recovery trueRawTokens=\x01 formattedTokens=\x01",
49044
49211
  "rust compaction-marker admission deferred: reason=capture_inputs fit=\x01 estimated=\x01 trusted=\x01 proxy_tokens=\x01 proxy_bytes=\x01 limit=\x01",
@@ -49199,7 +49366,6 @@ var init_issue_log_templates_generated = __esm(() => {
49199
49366
  "compaction-marker: no user boundary found at or before endMessageId \x01 (ordinal \x01); preserving existing marker\x020i",
49200
49367
  "compaction-marker: no user boundary found at or before endMessageId \x01 (ordinal \x01); preserving existing marker",
49201
49368
  "prefix trim: boundary \x01; pass=defer; no in-pass trim applied (boundary \x01 appears \x01 times in the live messages)",
49202
- "over-window first pass reduced: the request is about \x01 tokens (history started at \x01), under the \x01-token window",
49203
49369
  "latest-turn thinking recovery: provider rejected the bound turn again (rejection \x01, first=\x01 last=\x01); \x01 -> armed",
49204
49370
  "historian prompt fit: sized to \x01 (chunkTokens=\x01 sessionReferences=\x01 memories=\x01/\x01 seeds=\x01/\x01; requestedChunkTokens=\x01)\x020m",
49205
49371
  "system prompt hash changed: \x01 → \x01 (len=\x01), triggering flush (idle-expired request); presetChanged=\x01 elements=[\x01]",
@@ -49353,6 +49519,7 @@ var init_issue_log_templates_generated = __esm(() => {
49353
49519
  "[dreamer] map-memories: all \x01 path(s) for memory \x01 were rejected; recording host_rejected_fallback",
49354
49520
  "transform: model switch \x01 -> \x01/\x01 reset — percentage=\x01% tokens=\x01 — clearing stale model-specific state\x020s,1m,2m",
49355
49521
  "[dreamer] map-memories: splitting batch [\x01] into \x01 after timeout; retrying \x01 uncommitted mapping(s)",
49522
+ "[magic-context] storage permission tightening failures=\x01: storage root link \x01: \x01 is not a directory\x021p,2p",
49356
49523
  "transform: recovery was cleared during a pass that is not sent; armed again (\x01) for the next turn",
49357
49524
  "[magic-context] embedding worker stopped (\x01; pid \x01; inference running: yes (for \x01ms); stop took \x01ms)",
49358
49525
  "[magic-context] WARNING: \x01 configured \x01, but Oh My Pi does not know that model; provider suggests \x01\x021m",
@@ -49490,10 +49657,12 @@ var init_issue_log_templates_generated = __esm(() => {
49490
49657
  "[dreamer] retrospective: oversized timestamp cohort sessionIds=\x01 timestamp=\x01 skippedAtLeast=\x01\x020s",
49491
49658
  "[magic-context] WARNING: \x01 configured \x01, but Pi does not know that model; provider suggests \x01\x021m",
49492
49659
  "Pi compaction-marker clear: reason=clone-replaced endMessageId=\x01 ordinal=\x01 firstKeptEntryId=\x01\x020i",
49660
+ "Pi dreamer finalize: refusal spared for a call issued before steer delivery was confirmed \x01",
49493
49661
  "v2 refusal: interrupting the turn before the provider request arm=usage-unavailable cause=\x01",
49494
49662
  '[magic-context] Stripped deprecated "protected_tags" key during config location migration',
49495
49663
  "historian two-pass: editor failed (editor returned no usable text), falling back to draft",
49496
49664
  "historian: prompt refused before opening a child session: producer_prompt_fit_unavailable",
49665
+ "Pi dreamer finalize: refusal spared for a call issued before steer delivery was confirmed",
49497
49666
  "v2 refusal: interrupting the turn before the provider request arm=checkpoint-fit-estimate",
49498
49667
  "v2 refusal: interrupting the turn before the provider request arm=unsupported-session-api",
49499
49668
  "prompt_surface.tool_descriptions.\x01 is not a known ctx_* tool ID; the override was ignored.",
@@ -49617,6 +49786,7 @@ var init_issue_log_templates_generated = __esm(() => {
49617
49786
  "stable-id scheme cutover: stored=\x01 < current=\x01 — forcing execute+materialize this pass",
49618
49787
  "Pi held identity rebuild: prior prefix unavailable (\x01); applying the declared rebuild",
49619
49788
  "thinking binding recovery: stripped bound reasoning from \x01 assistant(s) [\x01]; flag=kept",
49789
+ "[magic-context] storage permission tightening failures=\x01: storage root link \x01: ENOTDIR\x021p",
49620
49790
  "context limit resolved: \x01 for \x01 (catalog \x01, overflow-detected \x01, proven accepted input \x01)\x021m",
49621
49791
  "pending ops WILL NOT APPLY — reason=\x01 pendingOps=not loaded (deferred pass) context=\x01%",
49622
49792
  'recomp partial code=\x01 reason="history model response did not validate for messages \x01-\x01"',
@@ -49645,6 +49815,8 @@ var init_issue_log_templates_generated = __esm(() => {
49645
49815
  "historian two-pass: editor failed (subagent run failed (\x01): \x01), falling back to draft",
49646
49816
  'historian no-op: stored compartments still invalid ("invalid range \x01-\x01"); backing off',
49647
49817
  "DEGRADED PASS \x01: LKG unavailable (compaction_off); refusing unreduced \x01-message input",
49818
+ "[magic-context] storage permission tightening failures=\x01: storage root link \x01: EACCES\x021p",
49819
+ "[magic-context] storage permission tightening failures=\x01: storage root link \x01: ENOENT\x021p",
49648
49820
  "channel2 ceiling nudge delivery skipped: claim no longer owned before send (state=\x01)",
49649
49821
  "[dreamer] retrospective: oversized timestamp cohort sessionIds=\x01 timestamp=\x01 skipped=\x01\x020s",
49650
49822
  "[magic-context] embedding endpoint blocked: embedding endpoint is not a valid URL: \x01",
@@ -49670,6 +49842,8 @@ var init_issue_log_templates_generated = __esm(() => {
49670
49842
  "transform: refused turn recovery reset — percentage=\x01% — clearing stale usage state",
49671
49843
  "request tools changed (kind=schemas, model=\x01, schemas \x01→\x01): releasing signed thinking\x020m",
49672
49844
  "mc-module: deprecated protected_tags is ignored for session \x01; use protected_tokens",
49845
+ "[magic-context] storage permission tightening failures=\x01: storage root link \x01: ELOOP\x021p",
49846
+ "[magic-context] storage permission tightening failures=\x01: storage root link \x01: EPERM\x021p",
49673
49847
  "rust pass disarmed emergency recovery via trusted-final-wire after none at \x01% usage",
49674
49848
  "[magic-context] slow write transaction: site=user_memory_candidate_insert held=\x01ms ",
49675
49849
  "historian publish stage: stage=dangling-boundary-check status=completed elapsed=\x01ms",
@@ -49703,7 +49877,6 @@ var init_issue_log_templates_generated = __esm(() => {
49703
49877
  "[magic-context] slow write transaction: site=user_memory_candidate_insert held=\x01ms",
49704
49878
  "[magic-context] local embedding pooling for \x01: \x01 pooling, normalization disabled (\x01)\x020m",
49705
49879
  "Ignoring project protected_tokens=\x01; it cannot lower resolved user/default floor \x01.",
49706
- 'recomp partial code=\x01 reason="historian made no forward progress after messages \x01-\x01"',
49707
49880
  "[dreamer] curate safety refusal: session_id=\x01 memory_id=\x01 verdict=\x01 reason=\x01 refused=\x01\x020s,4s",
49708
49881
  "[magic-context] slow write transaction: site=opencode_soft_refresh_cache held=\x01ms \x01",
49709
49882
  "[magic-context] slow write transaction: site=storage_meta_wrapup_acquire held=\x01ms \x01",
@@ -49778,6 +49951,7 @@ var init_issue_log_templates_generated = __esm(() => {
49778
49951
  "[magic-context] slow write transaction: site=opencode_materialize_cache held=\x01ms",
49779
49952
  "[magic-context] slow write transaction: site=storage_meta_wrapup_update held=\x01ms",
49780
49953
  "[session-projects] backfilled \x01 of \x01 unmapped sessions (skipped \x01 dead dirs) in \x01ms",
49954
+ 'recomp partial code=\x01 reason="Recomp made no forward progress after messages \x01-\x01."',
49781
49955
  "latest-turn thinking recovery: restore applied to the bound turn (first=\x01 last=\x01)",
49782
49956
  "[magic-context] slow write transaction: site=compartment_state_replace held=\x01ms \x01",
49783
49957
  "[magic-context] slow write transaction: site=embedding_identity_record held=\x01ms \x01",
@@ -50411,6 +50585,7 @@ var init_issue_log_templates_generated = __esm(() => {
50411
50585
  "channel2 terminal-run claim release failed; lease will heal:",
50412
50586
  "ctx_reduce permission read before freeze failed (fail-open):",
50413
50587
  "historian skipped: compartment lease held by another process",
50588
+ "Pi dreamer finalize: steer was handled by an input extension",
50414
50589
  "protected-tail stored-token map unavailable (live fallback):",
50415
50590
  "todowrite todos could not be read; cleared the todo snapshot",
50416
50591
  "transform refused degraded pass site=flushed-status-failure:",
@@ -50576,6 +50751,7 @@ var init_issue_log_templates_generated = __esm(() => {
50576
50751
  "historian post-publish step failed; publication stands: \x01",
50577
50752
  "reasoning clearing failed; restored original reasoning: \x01",
50578
50753
  "reclaimed compartment lease from dead owner holder=\x01 pid=\x01",
50754
+ "refusal notice skipped: no terminal viewing the session \x01",
50579
50755
  "rust refusal recovery could not read persisted history: \x01",
50580
50756
  "system prompt date restored after restart: real=\x01, using=\x01\x021s",
50581
50757
  "transform: wire-estimate pressure fallback unavailable: \x01",
@@ -50587,6 +50763,7 @@ var init_issue_log_templates_generated = __esm(() => {
50587
50763
  "DISCARDED CONTEXT RESULT: pending Pi transform decision",
50588
50764
  "event message.removed: invalidated tagger session cache",
50589
50765
  "note-nudge: triggerPending but no notes found, skipping",
50766
+ "refusal notice skipped: no terminal viewing the session",
50590
50767
  "rust refusal recovery could not read persisted history:",
50591
50768
  "the module refused this host's poll: malformed_response",
50592
50769
  "[dreamer] OpenCode 2 parent session lookup failed for \x01:\x020p",
@@ -50805,7 +50982,6 @@ var init_issue_log_templates_generated = __esm(() => {
50805
50982
  "[magic-context] host stall profiler: stop failed: \x01",
50806
50983
  "[magic-context] partial recomp validation failed: \x01",
50807
50984
  "[magic-context] schema-fence warning unavailable: \x01",
50808
- "[magic-context] storage-busy host refusal failed: \x01",
50809
50985
  "[v22-backfill] failed to start background runner: \x01",
50810
50986
  "cleanup after tagging-persistence-failure failed: \x01",
50811
50987
  "compartment agent: tail prime failed (non-fatal): \x01",
@@ -50826,7 +51002,6 @@ var init_issue_log_templates_generated = __esm(() => {
50826
51002
  "[dreamer] retrospective: window already processed",
50827
51003
  "[magic-context] failed to inject onnxruntime-web:",
50828
51004
  "[magic-context] schema-fence warning unavailable:",
50829
- "[magic-context] storage-busy host refusal failed:",
50830
51005
  "[search] message search runs in process (no-file)",
50831
51006
  "compaction mode switch: stripping signed thinking",
50832
51007
  "compartment agent: tail prime failed (non-fatal):",
@@ -50936,6 +51111,7 @@ var init_issue_log_templates_generated = __esm(() => {
50936
51111
  "[dreamer] user-memories: child session created \x01",
50937
51112
  "[magic-context] failed to show disabled toast: \x01",
50938
51113
  "[magic-context] maintenance tick (\x01) — projects=\x01",
51114
+ "[magic-context] resolved storage root link \x01 -> \x01\x020p",
50939
51115
  "[magic-context] v2 Channel 2 delivery deferred \x01",
50940
51116
  "[magic-context] v2 command registration failed \x01",
50941
51117
  "[model-retry] child session abort failed for \x01: \x01\x020p",
@@ -51021,6 +51197,7 @@ var init_issue_log_templates_generated = __esm(() => {
51021
51197
  "ctx_reduce permission read failed (ignored): \x01",
51022
51198
  "degraded pass size guard could not estimate: \x01",
51023
51199
  "DISCARDED CONTEXT RESULT: queued LKG capture \x01",
51200
+ "dreamer token budget: counting tool refusals \x01",
51024
51201
  "Magic Context child tool restriction failed: \x01",
51025
51202
  "proactive thinking strip: persistence threw: \x01",
51026
51203
  "system prompt sticky date record unreadable: \x01",
@@ -51039,6 +51216,7 @@ var init_issue_log_templates_generated = __esm(() => {
51039
51216
  "ctx_reduce permission read failed (ignored):",
51040
51217
  "degraded pass size guard could not estimate:",
51041
51218
  "DISCARDED CONTEXT RESULT: queued LKG capture",
51219
+ "dreamer token budget: counting tool refusals",
51042
51220
  "historian skipped: /ctx-wrapup became active",
51043
51221
  "proactive thinking strip: persistence threw:",
51044
51222
  "system prompt sticky date record not written",
@@ -51066,6 +51244,7 @@ var init_issue_log_templates_generated = __esm(() => {
51066
51244
  "channel2 delivery wrapper failed (ignored): \x01",
51067
51245
  "channel2 fold-cycle reset failed (ignored): \x01",
51068
51246
  "channel2 U-collapse reset failed (ignored): \x01",
51247
+ "dreamer token budget: refusal did not count \x01",
51069
51248
  "Failed to ensure project artifact gitignore \x01",
51070
51249
  "lkg_fit_basis=provider_input measured_input=\x01",
51071
51250
  "mc-module: aborting historian trigger for \x01: \x01",
@@ -51082,6 +51261,7 @@ var init_issue_log_templates_generated = __esm(() => {
51082
51261
  "channel2 delivery wrapper failed (ignored):",
51083
51262
  "channel2 fold-cycle reset failed (ignored):",
51084
51263
  "channel2 U-collapse reset failed (ignored):",
51264
+ "dreamer token budget: refusal did not count",
51085
51265
  "Failed to ensure project artifact gitignore",
51086
51266
  "historian skip: internal drain budget spent",
51087
51267
  "historian trigger eval: in-flight, skipping",
@@ -51538,10 +51718,12 @@ var init_issue_log_templates_generated = __esm(() => {
51538
51718
  "stored \x01 compartment event(s)",
51539
51719
  'recomp retry code=\x01 reason="\x01"',
51540
51720
  "historian retry \x01/\x01 after \x01ms: \x01",
51721
+ "host refusal notice failed: \x01",
51541
51722
  "rust session.status failed: \x01",
51542
51723
  "work-metrics update failed: \x01",
51543
51724
  "fallbackIdentityAndAdoption",
51544
51725
  "historian response received",
51726
+ "host refusal notice failed:",
51545
51727
  "prepareCompartmentInjection",
51546
51728
  "rust session.status failed:",
51547
51729
  "unconfirmedMigrationHolders",
@@ -51571,6 +51753,7 @@ var init_issue_log_templates_generated = __esm(() => {
51571
51753
  "DISCARDED CONTEXT RESULT \x01 \x01",
51572
51754
  "frozen_fit_unproven limit=\x01",
51573
51755
  "LKG durable clear failed: \x01",
51756
+ "recomp discarded staging: \x01",
51574
51757
  "refusal diagnostic failed \x01",
51575
51758
  "UI notification rejected: \x01",
51576
51759
  "[rpc] embed start failed:",
@@ -56663,7 +56846,7 @@ function removeDeprecatedReasoningAge(config) {
56663
56846
  import { spawnSync as spawnSync10 } from "node:child_process";
56664
56847
  import { existsSync as existsSync48, mkdtempSync as mkdtempSync4, readFileSync as readFileSync32, rmSync as rmSync9 } from "node:fs";
56665
56848
  import { createRequire as createRequire6 } from "node:module";
56666
- import { homedir as homedir21, tmpdir as tmpdir4 } from "node:os";
56849
+ import { homedir as homedir22, tmpdir as tmpdir4 } from "node:os";
56667
56850
  import { dirname as dirname27, join as join41, resolve as resolve21 } from "node:path";
56668
56851
  function formatSharedDbRowCounts(db) {
56669
56852
  return SHARED_DB_ROW_COUNT_TABLES.map((table) => {
@@ -56920,7 +57103,7 @@ function getUserNpmrcPath() {
56920
57103
  if (custom)
56921
57104
  return custom;
56922
57105
  const home = process.env.HOME?.trim();
56923
- return join41(home || homedir21(), ".npmrc");
57106
+ return join41(home || homedir22(), ".npmrc");
56924
57107
  }
56925
57108
  function collectNpmReleaseAgeWarnings() {
56926
57109
  const ageWarnings = [];
@@ -58847,9 +59030,9 @@ var init_logs_pi = __esm(() => {
58847
59030
 
58848
59031
  // src/commands/doctor-pi.ts
58849
59032
  import { execFileSync as execFileSync8, spawnSync as spawnSync11 } from "node:child_process";
58850
- import { existsSync as existsSync50, lstatSync as lstatSync6, readdirSync as readdirSync12, readFileSync as readFileSync34, rmSync as rmSync10 } from "node:fs";
59033
+ import { existsSync as existsSync50, lstatSync as lstatSync7, readdirSync as readdirSync12, readFileSync as readFileSync34, rmSync as rmSync10 } from "node:fs";
58851
59034
  import { createRequire as createRequire8 } from "node:module";
58852
- import { homedir as homedir22 } from "node:os";
59035
+ import { homedir as homedir23 } from "node:os";
58853
59036
  import { basename as basename8, isAbsolute as isAbsolute11, join as join44 } from "node:path";
58854
59037
  function depsFrom(options) {
58855
59038
  return {
@@ -59090,7 +59273,7 @@ function expectedPiCacheVersion(specifier, latest, lookupTag) {
59090
59273
  }
59091
59274
  function cacheSearchPaths(cwd) {
59092
59275
  const home = process.env.HOME?.trim();
59093
- const cacheHome = process.env.XDG_CACHE_HOME || join44(home || homedir22(), ".cache");
59276
+ const cacheHome = process.env.XDG_CACHE_HOME || join44(home || homedir23(), ".cache");
59094
59277
  const piCacheRoot = getPiCacheRoot();
59095
59278
  const xdgPi = join44(cacheHome, "pi");
59096
59279
  const agent = getPiAgentConfigDir();
@@ -59113,7 +59296,7 @@ function findPiMagicContextCacheDirs(cwd, expectedVersion, force = false) {
59113
59296
  return;
59114
59297
  let stat;
59115
59298
  try {
59116
- stat = lstatSync6(path);
59299
+ stat = lstatSync7(path);
59117
59300
  } catch {
59118
59301
  return;
59119
59302
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/magic-context",
3
- "version": "0.49.86",
3
+ "version": "0.49.89",
4
4
  "description": "Unified CLI for Magic Context — setup, doctor, and migration across OpenCode, Pi, and OMP",
5
5
  "keywords": [
6
6
  "opencode",