@cortexkit/magic-context 0.49.47 → 0.49.49

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 +536 -594
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1733,6 +1733,7 @@ import {
1733
1733
  readFileSync as readFileSync2,
1734
1734
  readlinkSync,
1735
1735
  realpathSync,
1736
+ unlinkSync,
1736
1737
  writeFileSync
1737
1738
  } from "node:fs";
1738
1739
  import * as os from "node:os";
@@ -1832,6 +1833,7 @@ function getLegacyOpenCodeMagicContextStorageDir() {
1832
1833
  }
1833
1834
  var STORAGE_BACKUP_WARNING_CHECKED;
1834
1835
  var init_data_path = __esm(() => {
1836
+ init_logger();
1835
1837
  init_test_temp_dir();
1836
1838
  STORAGE_BACKUP_WARNING_CHECKED = Symbol.for("magic-context.storage-backup-warning-checked");
1837
1839
  });
@@ -2872,7 +2874,7 @@ var init_jsonc_edit = __esm(() => {
2872
2874
  });
2873
2875
 
2874
2876
  // ../plugin/src/config/migrate-config-location.ts
2875
- import { existsSync as existsSync3, readFileSync as readFileSync3, rmSync as rmSync2, statSync as statSync2, unlinkSync } from "node:fs";
2877
+ import { existsSync as existsSync3, readFileSync as readFileSync3, rmSync as rmSync2, statSync as statSync2, unlinkSync as unlinkSync2 } from "node:fs";
2876
2878
  import { homedir as homedir3 } from "node:os";
2877
2879
  import { basename as basename2, dirname as dirname4, isAbsolute as isAbsolute2, join as join3 } from "node:path";
2878
2880
  function homeDir() {
@@ -3100,7 +3102,7 @@ function markLegacySourcesMovedAside(sources, targetPath, logger) {
3100
3102
  try {
3101
3103
  const original = readFileSync3(source.path, "utf-8");
3102
3104
  atomicWriteConfigFile(markerPath, movedMarkerContent(targetPath, basename2(source.path), original));
3103
- unlinkSync(source.path);
3105
+ unlinkSync2(source.path);
3104
3106
  info?.(`Moved legacy Magic Context config ${source.path} aside to ${markerPath}; now reading ${targetPath}`);
3105
3107
  } catch (err) {
3106
3108
  const msg = err instanceof Error ? err.message : String(err);
@@ -11472,7 +11474,7 @@ import {
11472
11474
  realpathSync as realpathSync2,
11473
11475
  renameSync as renameSync2,
11474
11476
  statSync as statSync3,
11475
- unlinkSync as unlinkSync2,
11477
+ unlinkSync as unlinkSync3,
11476
11478
  writeFileSync as writeFileSync3
11477
11479
  } from "node:fs";
11478
11480
  import { basename as basename3, dirname as dirname5, join as join4 } from "node:path";
@@ -11678,7 +11680,7 @@ function writeExclusiveBackup(backupPath, bytes, mode) {
11678
11680
  }
11679
11681
  } finally {
11680
11682
  try {
11681
- unlinkSync2(temporaryPath);
11683
+ unlinkSync3(temporaryPath);
11682
11684
  } catch {}
11683
11685
  }
11684
11686
  }
@@ -11701,7 +11703,7 @@ function writeTemporaryCandidate(configPath, bytes, mode) {
11701
11703
  } catch {}
11702
11704
  }
11703
11705
  try {
11704
- unlinkSync2(path);
11706
+ unlinkSync3(path);
11705
11707
  } catch {}
11706
11708
  if (error.code !== "EEXIST")
11707
11709
  throw error;
@@ -11764,7 +11766,7 @@ function loadRawConfigFile(options) {
11764
11766
  options.afterTemporaryWrite?.();
11765
11767
  const currentBytes = readFileSync4(options.configPath);
11766
11768
  if (!hasFlatKeys(currentBytes)) {
11767
- unlinkSync2(temporaryPath);
11769
+ unlinkSync3(temporaryPath);
11768
11770
  return {
11769
11771
  configPath: options.configPath,
11770
11772
  bytes: currentBytes,
@@ -11774,7 +11776,7 @@ function loadRawConfigFile(options) {
11774
11776
  };
11775
11777
  }
11776
11778
  if (!currentBytes.equals(observedBytes)) {
11777
- unlinkSync2(temporaryPath);
11779
+ unlinkSync3(temporaryPath);
11778
11780
  observedBytes = currentBytes;
11779
11781
  continue;
11780
11782
  }
@@ -11792,7 +11794,7 @@ function loadRawConfigFile(options) {
11792
11794
  } catch (error) {
11793
11795
  if (temporaryPath) {
11794
11796
  try {
11795
- unlinkSync2(temporaryPath);
11797
+ unlinkSync3(temporaryPath);
11796
11798
  } catch {}
11797
11799
  }
11798
11800
  return {
@@ -15787,52 +15789,9 @@ var init_dashboard_install = __esm(() => {
15787
15789
  WINDOWS_UNINSTALL_KEY = `Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${DASHBOARD_PRODUCT_NAME}`;
15788
15790
  });
15789
15791
 
15790
- // src/lib/docs-proposal-gitignore.ts
15791
- import { appendFileSync as appendFileSync2, existsSync as existsSync8, readFileSync as readFileSync7 } from "node:fs";
15792
- import { join as join6 } from "node:path";
15793
- function coversProposalState(line) {
15794
- const rule = line.trim();
15795
- if (rule === "" || rule.startsWith("#") || rule.startsWith("!"))
15796
- return false;
15797
- const normalized = rule.replace(/^\//, "").replace(/^\*\*\//, "").replace(/\/(\*\*?)?$/, "");
15798
- return COVERING_PATHS.has(normalized);
15799
- }
15800
- function ensureDocsProposalGitignore(projectDir) {
15801
- if (!existsSync8(join6(projectDir, ".git")))
15802
- return { status: "not-a-repository" };
15803
- const path = join6(projectDir, ".gitignore");
15804
- try {
15805
- const text = existsSync8(path) ? readFileSync7(path, "utf8") : "";
15806
- if (text.split(/\r?\n/).some(coversProposalState))
15807
- return { status: "covered" };
15808
- const nestedPath = join6(projectDir, ".cortexkit", ".gitignore");
15809
- if (existsSync8(nestedPath)) {
15810
- const nested = readFileSync7(nestedPath, "utf8").split(/\r?\n/);
15811
- if (nested.some((line) => /^\/?magic-context(\/(\*\*?)?)?$/.test(line.trim()))) {
15812
- return { status: "covered" };
15813
- }
15814
- }
15815
- appendFileSync2(path, `${text && !text.endsWith(`
15816
- `) ? `
15817
- ` : ""}.cortexkit/magic-context/
15818
- `);
15819
- return { status: "added", path };
15820
- } catch (error) {
15821
- return {
15822
- status: "failed",
15823
- path,
15824
- error: error instanceof Error ? error.message : String(error)
15825
- };
15826
- }
15827
- }
15828
- var COVERING_PATHS;
15829
- var init_docs_proposal_gitignore = __esm(() => {
15830
- COVERING_PATHS = new Set([".cortexkit", ".cortexkit/magic-context"]);
15831
- });
15832
-
15833
15792
  // src/lib/find-on-path.ts
15834
- import { accessSync as accessSync2, constants as constants2, existsSync as existsSync9, statSync as statSync6 } from "node:fs";
15835
- import { delimiter, join as join7 } from "node:path";
15793
+ import { accessSync as accessSync2, constants as constants2, existsSync as existsSync8, statSync as statSync6 } from "node:fs";
15794
+ import { delimiter, join as join6 } from "node:path";
15836
15795
  function findOnPath(binary) {
15837
15796
  const PATH = process.env.PATH;
15838
15797
  if (typeof PATH !== "string" || PATH.length === 0)
@@ -15844,7 +15803,7 @@ function findOnPath(binary) {
15844
15803
  if (!dir)
15845
15804
  continue;
15846
15805
  for (const candidate of candidates) {
15847
- const fullPath = join7(dir, candidate);
15806
+ const fullPath = join6(dir, candidate);
15848
15807
  if (isExecutableFile(fullPath, isWindows))
15849
15808
  return fullPath;
15850
15809
  }
@@ -15853,7 +15812,7 @@ function findOnPath(binary) {
15853
15812
  }
15854
15813
  function isExecutableFile(path, isWindows = process.platform === "win32") {
15855
15814
  try {
15856
- if (!existsSync9(path))
15815
+ if (!existsSync8(path))
15857
15816
  return false;
15858
15817
  const st = statSync6(path);
15859
15818
  if (!st.isFile())
@@ -15870,28 +15829,28 @@ function isExecutableFile(path, isWindows = process.platform === "win32") {
15870
15829
  var init_find_on_path = () => {};
15871
15830
 
15872
15831
  // src/lib/paths.ts
15873
- import { existsSync as existsSync10, readdirSync as readdirSync2, statSync as statSync7 } from "node:fs";
15832
+ import { existsSync as existsSync9, readdirSync as readdirSync2, statSync as statSync7 } from "node:fs";
15874
15833
  import { homedir as homedir7 } from "node:os";
15875
- import { delimiter as delimiter2, dirname as dirname8, join as join8, resolve as resolve3 } from "node:path";
15834
+ import { delimiter as delimiter2, dirname as dirname8, join as join7, resolve as resolve3 } from "node:path";
15876
15835
  function getOpenCodeConfigDir() {
15877
15836
  const envDir = process.env.OPENCODE_CONFIG_DIR?.trim();
15878
15837
  if (envDir)
15879
15838
  return envDir;
15880
15839
  if (process.platform === "win32") {
15881
- return join8(homedir7(), ".config", "opencode");
15840
+ return join7(homedir7(), ".config", "opencode");
15882
15841
  }
15883
- const xdgConfig = process.env.XDG_CONFIG_HOME || join8(homedir7(), ".config");
15884
- return join8(xdgConfig, "opencode");
15842
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join7(homedir7(), ".config");
15843
+ return join7(xdgConfig, "opencode");
15885
15844
  }
15886
15845
  function findOmoConfig(configDir) {
15887
15846
  const locations = [
15888
- join8(configDir, "oh-my-openagent.jsonc"),
15889
- join8(configDir, "oh-my-openagent.json"),
15890
- join8(configDir, "oh-my-opencode.jsonc"),
15891
- join8(configDir, "oh-my-opencode.json")
15847
+ join7(configDir, "oh-my-openagent.jsonc"),
15848
+ join7(configDir, "oh-my-openagent.json"),
15849
+ join7(configDir, "oh-my-opencode.jsonc"),
15850
+ join7(configDir, "oh-my-opencode.json")
15892
15851
  ];
15893
15852
  for (const loc of locations) {
15894
- if (existsSync10(loc))
15853
+ if (existsSync9(loc))
15895
15854
  return loc;
15896
15855
  }
15897
15856
  return null;
@@ -15902,24 +15861,24 @@ function detectConfigPaths() {
15902
15861
  let opencodeConfigFormat;
15903
15862
  let tuiConfig;
15904
15863
  let tuiConfigFormat;
15905
- const jsoncPath = join8(configDir, "opencode.jsonc");
15906
- const jsonPath = join8(configDir, "opencode.json");
15907
- if (existsSync10(jsoncPath)) {
15864
+ const jsoncPath = join7(configDir, "opencode.jsonc");
15865
+ const jsonPath = join7(configDir, "opencode.json");
15866
+ if (existsSync9(jsoncPath)) {
15908
15867
  opencodeConfig = jsoncPath;
15909
15868
  opencodeConfigFormat = "jsonc";
15910
- } else if (existsSync10(jsonPath)) {
15869
+ } else if (existsSync9(jsonPath)) {
15911
15870
  opencodeConfig = jsonPath;
15912
15871
  opencodeConfigFormat = "json";
15913
15872
  } else {
15914
15873
  opencodeConfig = jsoncPath;
15915
15874
  opencodeConfigFormat = "none";
15916
15875
  }
15917
- const tuiJsoncPath = join8(configDir, "tui.jsonc");
15918
- const tuiJsonPath = join8(configDir, "tui.json");
15919
- if (existsSync10(tuiJsoncPath)) {
15876
+ const tuiJsoncPath = join7(configDir, "tui.jsonc");
15877
+ const tuiJsonPath = join7(configDir, "tui.json");
15878
+ if (existsSync9(tuiJsoncPath)) {
15920
15879
  tuiConfig = tuiJsoncPath;
15921
15880
  tuiConfigFormat = "jsonc";
15922
- } else if (existsSync10(tuiJsonPath)) {
15881
+ } else if (existsSync9(tuiJsonPath)) {
15923
15882
  tuiConfig = tuiJsonPath;
15924
15883
  tuiConfigFormat = "json";
15925
15884
  } else {
@@ -15944,31 +15903,31 @@ function getPiAgentDir() {
15944
15903
  const envDir = process.env.PI_CODING_AGENT_DIR?.trim();
15945
15904
  if (envDir)
15946
15905
  return envDir;
15947
- return join8(envFirstHomeDir(), ".pi", "agent");
15906
+ return join7(envFirstHomeDir(), ".pi", "agent");
15948
15907
  }
15949
15908
  function getPiAgentConfigDir() {
15950
15909
  return getPiAgentDir();
15951
15910
  }
15952
15911
  function getPiSessionsRoot() {
15953
- return join8(getPiAgentDir(), "sessions");
15912
+ return join7(getPiAgentDir(), "sessions");
15954
15913
  }
15955
15914
  function getPiCacheRoot() {
15956
- return join8(dirname8(getPiAgentDir()), "cache");
15915
+ return join7(dirname8(getPiAgentDir()), "cache");
15957
15916
  }
15958
15917
  function getPiUserConfigPath() {
15959
15918
  return resolveCortexKitUserConfigPath();
15960
15919
  }
15961
15920
  function getPiUserExtensionsPath() {
15962
- return join8(getPiAgentConfigDir(), "settings.json");
15921
+ return join7(getPiAgentConfigDir(), "settings.json");
15963
15922
  }
15964
15923
  function resolveOmpPaths() {
15965
15924
  const rawProfile = process.env.OMP_PROFILE ?? process.env.PI_PROFILE;
15966
15925
  const normalizedProfile = rawProfile?.trim();
15967
15926
  const profile = normalizedProfile && normalizedProfile !== "default" && /^[a-z0-9][a-z0-9._-]{0,63}$/.test(normalizedProfile) ? normalizedProfile : undefined;
15968
15927
  const configDirName = process.env.PI_CONFIG_DIR?.trim() || ".omp";
15969
- const baseConfigRoot = join8(envFirstHomeDir(), configDirName);
15970
- const configRoot = profile ? join8(baseConfigRoot, "profiles", profile) : baseConfigRoot;
15971
- const defaultAgentDir = join8(configRoot, "agent");
15928
+ const baseConfigRoot = join7(envFirstHomeDir(), configDirName);
15929
+ const configRoot = profile ? join7(baseConfigRoot, "profiles", profile) : baseConfigRoot;
15930
+ const defaultAgentDir = join7(configRoot, "agent");
15972
15931
  const override = profile ? undefined : process.env.PI_CODING_AGENT_DIR?.trim();
15973
15932
  const agentDir = override ? resolve3(override) : defaultAgentDir;
15974
15933
  const canUseXdg = (process.platform === "linux" || process.platform === "darwin") && agentDir === defaultAgentDir;
@@ -15976,9 +15935,9 @@ function resolveOmpPaths() {
15976
15935
  if (canUseXdg) {
15977
15936
  const xdgDataHome = process.env.XDG_DATA_HOME?.trim();
15978
15937
  if (xdgDataHome) {
15979
- const appRoot = join8(xdgDataHome, "omp");
15980
- const candidate = profile ? join8(appRoot, "profiles", profile) : appRoot;
15981
- if (existsSync10(candidate))
15938
+ const appRoot = join7(xdgDataHome, "omp");
15939
+ const candidate = profile ? join7(appRoot, "profiles", profile) : appRoot;
15940
+ if (existsSync9(candidate))
15982
15941
  dataRoot = candidate;
15983
15942
  }
15984
15943
  }
@@ -15988,8 +15947,8 @@ function resolveOmpPaths() {
15988
15947
  agentDir,
15989
15948
  dataRoot,
15990
15949
  dataAgentRoot,
15991
- pluginsDir: join8(dataRoot, "plugins"),
15992
- sessionsRoot: join8(dataAgentRoot, "sessions")
15950
+ pluginsDir: join7(dataRoot, "plugins"),
15951
+ sessionsRoot: join7(dataAgentRoot, "sessions")
15993
15952
  };
15994
15953
  }
15995
15954
  function getOmpAgentDir() {
@@ -15999,7 +15958,7 @@ function getOmpSessionsRoot() {
15999
15958
  return resolveOmpPaths().sessionsRoot;
16000
15959
  }
16001
15960
  function getOmpConfigPath() {
16002
- return join8(resolveOmpPaths().agentDir, "config.yml");
15961
+ return join7(resolveOmpPaths().agentDir, "config.yml");
16003
15962
  }
16004
15963
  function getOmpPackageDir() {
16005
15964
  const value = process.env.PI_PACKAGE_DIR?.trim();
@@ -16015,7 +15974,7 @@ function getOmpPackageDir() {
16015
15974
  function getOmpNonGlobalConfigSources(cwd = process.cwd()) {
16016
15975
  const sources = getOmpConfigOverlayPaths(cwd);
16017
15976
  const projectConfig = resolve3(cwd, ".omp", "config.yml");
16018
- if (existsSync10(projectConfig))
15977
+ if (existsSync9(projectConfig))
16019
15978
  sources.push(projectConfig);
16020
15979
  return [...new Set(sources)];
16021
15980
  }
@@ -16023,7 +15982,7 @@ function getOmpConfigOverlayPaths(cwd = process.cwd()) {
16023
15982
  return process.env.PI_CONFIG_FILES?.split(delimiter2).map((entry) => entry.trim()).filter(Boolean).map((entry) => {
16024
15983
  if (entry === "~")
16025
15984
  return envFirstHomeDir();
16026
- const expanded = entry.startsWith("~/") || entry.startsWith("~\\") ? join8(envFirstHomeDir(), entry.slice(2)) : entry;
15985
+ const expanded = entry.startsWith("~/") || entry.startsWith("~\\") ? join7(envFirstHomeDir(), entry.slice(2)) : entry;
16027
15986
  return resolve3(cwd, expanded);
16028
15987
  }) ?? [];
16029
15988
  }
@@ -16031,7 +15990,7 @@ function getOmpPluginsDir() {
16031
15990
  return resolveOmpPaths().pluginsDir;
16032
15991
  }
16033
15992
  function getOmpPluginsLockPath() {
16034
- return join8(resolveOmpPaths().pluginsDir, "omp-plugins.lock.json");
15993
+ return join7(resolveOmpPaths().pluginsDir, "omp-plugins.lock.json");
16035
15994
  }
16036
15995
  function getOmpUserConfigPath() {
16037
15996
  return resolveCortexKitUserConfigPath();
@@ -16043,12 +16002,12 @@ function getMagicContextHistorianDir2(harness) {
16043
16002
  return getMagicContextHistorianDir(harness);
16044
16003
  }
16045
16004
  function getOpenCodePluginCacheDir() {
16046
- const xdg = process.env.XDG_CACHE_HOME || join8(homedir7(), ".cache");
16047
- return join8(xdg, "opencode", "packages");
16005
+ const xdg = process.env.XDG_CACHE_HOME || join7(homedir7(), ".cache");
16006
+ return join7(xdg, "opencode", "packages");
16048
16007
  }
16049
16008
  function getOpenCodeV2NpmCacheDir() {
16050
- const xdg = process.env.XDG_CACHE_HOME || join8(homedir7(), ".cache");
16051
- return join8(xdg, "opencode", "npm");
16009
+ const xdg = process.env.XDG_CACHE_HOME || join7(homedir7(), ".cache");
16010
+ return join7(xdg, "opencode", "npm");
16052
16011
  }
16053
16012
  function isDir(path) {
16054
16013
  try {
@@ -16069,7 +16028,7 @@ function dirSizeBytes(path) {
16069
16028
  try {
16070
16029
  const entries = readdirSync2(cur, { withFileTypes: true });
16071
16030
  for (const entry of entries) {
16072
- const child = join8(cur, entry.name);
16031
+ const child = join7(cur, entry.name);
16073
16032
  if (entry.isDirectory()) {
16074
16033
  stack.push(child);
16075
16034
  } else if (entry.isFile()) {
@@ -16090,7 +16049,7 @@ var init_paths = __esm(() => {
16090
16049
  // src/lib/pi-helpers.ts
16091
16050
  import { execFileSync, spawnSync } from "node:child_process";
16092
16051
  import { homedir as homedir8 } from "node:os";
16093
- import { extname, join as join9 } from "node:path";
16052
+ import { extname, join as join8 } from "node:path";
16094
16053
  function getPiCommandInvocation(piPath, args) {
16095
16054
  const extension = extname(piPath).toLowerCase();
16096
16055
  if (extension !== ".cmd" && extension !== ".bat") {
@@ -16104,7 +16063,7 @@ function detectPiBinary() {
16104
16063
  if (fromPath)
16105
16064
  return { path: fromPath, source: "path" };
16106
16065
  const home = process.env.HOME?.trim() || homedir8();
16107
- const homeCandidate = process.platform === "win32" ? join9(home, ".pi", "bin", "pi.cmd") : join9(home, ".pi", "bin", "pi");
16066
+ const homeCandidate = process.platform === "win32" ? join8(home, ".pi", "bin", "pi.cmd") : join8(home, ".pi", "bin", "pi");
16108
16067
  if (isExecutableFile(homeCandidate))
16109
16068
  return { path: homeCandidate, source: "home" };
16110
16069
  return null;
@@ -16193,9 +16152,9 @@ var init_pi_helpers = __esm(() => {
16193
16152
 
16194
16153
  // src/lib/omp-helpers.ts
16195
16154
  import { spawnSync as spawnSync2 } from "node:child_process";
16196
- import { existsSync as existsSync11, readFileSync as readFileSync8 } from "node:fs";
16155
+ import { existsSync as existsSync10, readFileSync as readFileSync7 } from "node:fs";
16197
16156
  import { homedir as homedir9 } from "node:os";
16198
- import { extname as extname2, join as join10 } from "node:path";
16157
+ import { extname as extname2, join as join9 } from "node:path";
16199
16158
  function detectOmpPackageCli() {
16200
16159
  const packageDir = getOmpPackageDir();
16201
16160
  if (!packageDir)
@@ -16203,11 +16162,11 @@ function detectOmpPackageCli() {
16203
16162
  if (!findOnPath("bun"))
16204
16163
  return null;
16205
16164
  try {
16206
- const manifest = JSON.parse(readFileSync8(join10(packageDir, "package.json"), "utf-8"));
16165
+ const manifest = JSON.parse(readFileSync7(join9(packageDir, "package.json"), "utf-8"));
16207
16166
  if (manifest.name !== "@oh-my-pi/pi-coding-agent")
16208
16167
  return null;
16209
- const cli = join10(packageDir, "dist", "cli.js");
16210
- return existsSync11(cli) ? cli : null;
16168
+ const cli = join9(packageDir, "dist", "cli.js");
16169
+ return existsSync10(cli) ? cli : null;
16211
16170
  } catch {
16212
16171
  return null;
16213
16172
  }
@@ -16222,13 +16181,13 @@ function getOmpCommandInvocation(ompPath, args) {
16222
16181
  }
16223
16182
  function getOmpFallbackCandidates(platform, home, appData) {
16224
16183
  if (platform !== "win32") {
16225
- return [join10(home, ".bun", "bin", "omp"), join10(home, ".local", "bin", "omp")];
16184
+ return [join9(home, ".bun", "bin", "omp"), join9(home, ".local", "bin", "omp")];
16226
16185
  }
16227
16186
  const npmRoot = appData?.trim();
16228
16187
  return [
16229
- ...npmRoot ? [join10(npmRoot, "npm", "omp.cmd"), join10(npmRoot, "npm", "omp.exe")] : [],
16230
- join10(home, ".bun", "bin", "omp.exe"),
16231
- join10(home, ".bun", "bin", "omp.cmd")
16188
+ ...npmRoot ? [join9(npmRoot, "npm", "omp.cmd"), join9(npmRoot, "npm", "omp.exe")] : [],
16189
+ join9(home, ".bun", "bin", "omp.exe"),
16190
+ join9(home, ".bun", "bin", "omp.cmd")
16232
16191
  ];
16233
16192
  }
16234
16193
  function detectOmpBinary() {
@@ -16351,8 +16310,8 @@ var init_omp_helpers = __esm(() => {
16351
16310
  });
16352
16311
 
16353
16312
  // src/adapters/omp.ts
16354
- import { existsSync as existsSync12, readFileSync as readFileSync9 } from "node:fs";
16355
- import { join as join11 } from "node:path";
16313
+ import { existsSync as existsSync11, readFileSync as readFileSync8 } from "node:fs";
16314
+ import { join as join10 } from "node:path";
16356
16315
 
16357
16316
  class OmpAdapter {
16358
16317
  kind = "omp";
@@ -16452,8 +16411,8 @@ class OmpAdapter {
16452
16411
  return "Install OMP: https://omp.sh (npm: @oh-my-pi/pi-coding-agent)";
16453
16412
  }
16454
16413
  getPluginCacheInfo() {
16455
- const path = join11(getOmpPluginsDir(), "cache");
16456
- return [{ path, exists: existsSync12(path), sizeBytes: dirSizeBytes(path) }];
16414
+ const path = join10(getOmpPluginsDir(), "cache");
16415
+ return [{ path, exists: existsSync11(path), sizeBytes: dirSizeBytes(path) }];
16457
16416
  }
16458
16417
  getLogPath() {
16459
16418
  return getMagicContextLogPath2("omp");
@@ -16466,7 +16425,7 @@ class OmpAdapter {
16466
16425
  }
16467
16426
  readRuntimeEnabled(configPath) {
16468
16427
  try {
16469
- const lock = JSON.parse(readFileSync9(configPath, "utf-8"));
16428
+ const lock = JSON.parse(readFileSync8(configPath, "utf-8"));
16470
16429
  const enabled = lock.plugins?.[OMP_PLUGIN_PACKAGE]?.enabled;
16471
16430
  return typeof enabled === "boolean" ? enabled : undefined;
16472
16431
  } catch {
@@ -16494,9 +16453,9 @@ var init_omp = __esm(() => {
16494
16453
  });
16495
16454
 
16496
16455
  // ../plugin/src/shared/opencode-db-path.ts
16497
- import { existsSync as existsSync13, readdirSync as readdirSync3, statSync as statSync8 } from "node:fs";
16456
+ import { existsSync as existsSync12, readdirSync as readdirSync3, statSync as statSync8 } from "node:fs";
16498
16457
  import { homedir as homedir10 } from "node:os";
16499
- import { isAbsolute as isAbsolute4, join as join12, resolve as resolve4 } from "node:path";
16458
+ import { isAbsolute as isAbsolute4, join as join11, resolve as resolve4 } from "node:path";
16500
16459
  function openCodeHostGenerationFromVersion(version) {
16501
16460
  const text = version ?? "";
16502
16461
  if (/(?:^|\s|v)0\.0\.0-(?:beta|dev)-/.test(text))
@@ -16505,7 +16464,7 @@ function openCodeHostGenerationFromVersion(version) {
16505
16464
  return Number.isFinite(major) && major >= 2 ? "v2" : "v1";
16506
16465
  }
16507
16466
  function openCodeDataDir(env = process.env, dataHome) {
16508
- return join12(dataHome ?? env.XDG_DATA_HOME ?? join12(homedir10(), ".local", "share"), "opencode");
16467
+ return join11(dataHome ?? env.XDG_DATA_HOME ?? join11(homedir10(), ".local", "share"), "opencode");
16509
16468
  }
16510
16469
  function environmentKey(dataDir, hostGeneration, channel, env) {
16511
16470
  return [
@@ -16517,7 +16476,7 @@ function environmentKey(dataDir, hostGeneration, channel, env) {
16517
16476
  ].join("\x00");
16518
16477
  }
16519
16478
  function channelPath(dataDir, channel) {
16520
- return ["latest", "beta", "prod"].includes(channel) ? join12(dataDir, "opencode.db") : join12(dataDir, `opencode-${channel}.db`);
16479
+ return ["latest", "beta", "prod"].includes(channel) ? join11(dataDir, "opencode.db") : join11(dataDir, `opencode-${channel}.db`);
16521
16480
  }
16522
16481
  function discoveredCandidateNames(dataDir) {
16523
16482
  const names = ["opencode.db", "opencode-local.db", "opencode-dev.db"];
@@ -16529,7 +16488,7 @@ function discoveredCandidateNames(dataDir) {
16529
16488
  }
16530
16489
  function discoverOpenCodeDb(dataDir) {
16531
16490
  const candidates = discoveredCandidateNames(dataDir).map((name, order) => {
16532
- const path = join12(dataDir, name);
16491
+ const path = join11(dataDir, name);
16533
16492
  try {
16534
16493
  const metadata = statSync8(path);
16535
16494
  return metadata.isFile() ? { path, order, mtimeMs: metadata.mtimeMs } : null;
@@ -16539,7 +16498,7 @@ function discoverOpenCodeDb(dataDir) {
16539
16498
  });
16540
16499
  const existing = candidates.filter((candidate) => candidate !== null).sort((left, right) => right.mtimeMs - left.mtimeMs || left.order - right.order)[0];
16541
16500
  if (!existing) {
16542
- return { path: join12(dataDir, "opencode.db"), source: "default", channel: null };
16501
+ return { path: join11(dataDir, "opencode.db"), source: "default", channel: null };
16543
16502
  }
16544
16503
  const name = existing.path.slice(dataDir.length + 1);
16545
16504
  const channel = name === "opencode.db" ? null : name.slice("opencode-".length, -".db".length) || null;
@@ -16552,14 +16511,14 @@ function resolveV1Fresh(dataDir, env = process.env) {
16552
16511
  return { path: explicit, source: "OPENCODE_DB", channel: null };
16553
16512
  }
16554
16513
  return {
16555
- path: isAbsolute4(explicit) ? explicit : join12(dataDir, explicit),
16514
+ path: isAbsolute4(explicit) ? explicit : join11(dataDir, explicit),
16556
16515
  source: "OPENCODE_DB",
16557
16516
  channel: null
16558
16517
  };
16559
16518
  }
16560
16519
  const disableChannelDb = env.OPENCODE_DISABLE_CHANNEL_DB;
16561
16520
  if (disableChannelDb === "1" || disableChannelDb === "true") {
16562
- return { path: join12(dataDir, "opencode.db"), source: "default", channel: null };
16521
+ return { path: join11(dataDir, "opencode.db"), source: "default", channel: null };
16563
16522
  }
16564
16523
  const channel = env.OPENCODE_CHANNEL;
16565
16524
  if (channel !== undefined && channel.length > 0) {
@@ -16593,7 +16552,7 @@ function resolveOpenCodeDbPath(hostGeneration = "v1", options = {}) {
16593
16552
  const dataDir = openCodeDataDir(env, options.dataHome);
16594
16553
  const channel = options.channel ?? env.OPENCODE_CHANNEL;
16595
16554
  const key = environmentKey(dataDir, hostGeneration, channel, env);
16596
- if (cachedResolution?.key === key && (!cachedResolution.existed || existsSync13(cachedResolution.resolution.path))) {
16555
+ if (cachedResolution?.key === key && (!cachedResolution.existed || existsSync12(cachedResolution.resolution.path))) {
16597
16556
  if (cachedResolution.existed)
16598
16557
  return cachedResolution.resolution;
16599
16558
  }
@@ -16601,7 +16560,7 @@ function resolveOpenCodeDbPath(hostGeneration = "v1", options = {}) {
16601
16560
  cachedResolution = {
16602
16561
  key,
16603
16562
  resolution,
16604
- existed: resolution.path !== ":memory:" && existsSync13(resolution.path)
16563
+ existed: resolution.path !== ":memory:" && existsSync12(resolution.path)
16605
16564
  };
16606
16565
  return resolution;
16607
16566
  }
@@ -16641,7 +16600,7 @@ function assertOpenCodeStoreGeneration(db, expected, path, schema = "main") {
16641
16600
  throw new Error(`OpenCode store generation mismatch at ${path}: expected ${expected}, found ${actual}; refusing generation-specific database access`);
16642
16601
  }
16643
16602
  function openCodeDbPathExists(resolution = resolveOpenCodeDbPath()) {
16644
- return resolution.path !== ":memory:" && existsSync13(resolution.path);
16603
+ return resolution.path !== ":memory:" && existsSync12(resolution.path);
16645
16604
  }
16646
16605
  function getOpenCodeDbProbeDescriptions(resolution = resolveOpenCodeDbPath()) {
16647
16606
  if (resolution.source === "OPENCODE_DB")
@@ -16651,10 +16610,10 @@ function getOpenCodeDbProbeDescriptions(resolution = resolveOpenCodeDbPath()) {
16651
16610
  }
16652
16611
  const dataDir = openCodeDataDir();
16653
16612
  return [
16654
- join12(dataDir, "opencode.db"),
16655
- join12(dataDir, "opencode-local.db"),
16656
- join12(dataDir, "opencode-dev.db"),
16657
- join12(dataDir, "opencode-<channel>.db")
16613
+ join11(dataDir, "opencode.db"),
16614
+ join11(dataDir, "opencode-local.db"),
16615
+ join11(dataDir, "opencode-dev.db"),
16616
+ join11(dataDir, "opencode-<channel>.db")
16658
16617
  ];
16659
16618
  }
16660
16619
  function lookedForText(resolution) {
@@ -24560,7 +24519,7 @@ var init_project_directory_key = () => {};
24560
24519
 
24561
24520
  // ../plugin/src/shared/rpc-utils.ts
24562
24521
  import { execFile as execFile2, execFileSync as execFileSync2 } from "node:child_process";
24563
- import { readFileSync as readFileSync10 } from "node:fs";
24522
+ import { readFileSync as readFileSync9 } from "node:fs";
24564
24523
  function isOwnRpcServerRecord(record) {
24565
24524
  return record.pid === process.pid && record.instance_id !== undefined && ownRpcServerInstanceIds.has(record.instance_id);
24566
24525
  }
@@ -25155,7 +25114,7 @@ var init_rpc_utils = __esm(() => {
25155
25114
  "cljs/dist",
25156
25115
  "dist/bundle/cli"
25157
25116
  ];
25158
- rpcIdentityReadFileSync = readFileSync10;
25117
+ rpcIdentityReadFileSync = readFileSync9;
25159
25118
  rpcIdentityExecFileSync = execFileSync2;
25160
25119
  rpcIdentityProcessKill = process.kill;
25161
25120
  rpcProcessListExecFileSync = execFileSync2;
@@ -25196,23 +25155,23 @@ var init_opencode_plugin_registration = __esm(() => {
25196
25155
  });
25197
25156
 
25198
25157
  // src/lib/opencode-plugin-cache.ts
25199
- import { readdirSync as readdirSync4, readFileSync as readFileSync11 } from "node:fs";
25200
- import { join as join13 } from "node:path";
25158
+ import { readdirSync as readdirSync4, readFileSync as readFileSync10 } from "node:fs";
25159
+ import { join as join12 } from "node:path";
25201
25160
  function getOpenCodePluginCacheRoots() {
25202
25161
  const cacheDir = getOpenCodePluginCacheDir();
25203
25162
  return [
25204
- join13(cacheDir, OPENCODE_PLUGIN_ENTRY_WITH_VERSION),
25205
- join13(cacheDir, OPENCODE_PLUGIN_NAME)
25163
+ join12(cacheDir, OPENCODE_PLUGIN_ENTRY_WITH_VERSION),
25164
+ join12(cacheDir, OPENCODE_PLUGIN_NAME)
25206
25165
  ];
25207
25166
  }
25208
25167
  function getOpenCodePluginPackageJsonPath(pluginCacheRoot) {
25209
- return join13(pluginCacheRoot, "node_modules", ...OPENCODE_PLUGIN_NAME.split("/"), "package.json");
25168
+ return join12(pluginCacheRoot, "node_modules", ...OPENCODE_PLUGIN_NAME.split("/"), "package.json");
25210
25169
  }
25211
25170
  function getOpenCodePluginPackageJsonPaths() {
25212
25171
  return getOpenCodePluginCacheRoots().map(getOpenCodePluginPackageJsonPath);
25213
25172
  }
25214
25173
  function getOpenCodeV2PluginCacheSlot(npmCacheDir = getOpenCodeV2NpmCacheDir(), spec = "latest") {
25215
- return join13(npmCacheDir, ...`${OPENCODE_PLUGIN_NAME}@${spec}`.split("/"));
25174
+ return join12(npmCacheDir, ...`${OPENCODE_PLUGIN_NAME}@${spec}`.split("/"));
25216
25175
  }
25217
25176
  function openCodeV2PluginSpecOf(specifier) {
25218
25177
  if (specifier === OPENCODE_PLUGIN_NAME)
@@ -25265,7 +25224,7 @@ function pluginEntrySpecifier(entry) {
25265
25224
  }
25266
25225
  function listOpenCodeV2PluginCacheSlots(npmCacheDir = getOpenCodeV2NpmCacheDir()) {
25267
25226
  const [scope = "", name = ""] = OPENCODE_PLUGIN_NAME.split("/");
25268
- const scopeDir = join13(npmCacheDir, scope);
25227
+ const scopeDir = join12(npmCacheDir, scope);
25269
25228
  let names;
25270
25229
  try {
25271
25230
  names = readdirSync4(scopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith(`${name}@`)).map((entry) => entry.name);
@@ -25273,7 +25232,7 @@ function listOpenCodeV2PluginCacheSlots(npmCacheDir = getOpenCodeV2NpmCacheDir()
25273
25232
  return [];
25274
25233
  }
25275
25234
  return names.map((dirName) => {
25276
- const slot = join13(scopeDir, dirName);
25235
+ const slot = join12(scopeDir, dirName);
25277
25236
  return {
25278
25237
  spec: dirName.slice(name.length + 1),
25279
25238
  slot,
@@ -25289,7 +25248,7 @@ function getOpenCodeV2ActiveGeneration(slot) {
25289
25248
  try {
25290
25249
  const generations = readdirSync4(slot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && /^\d+$/.test(entry.name)).map((entry) => entry.name).sort((a, b) => Number(a) - Number(b));
25291
25250
  const newest = generations.at(-1);
25292
- return newest === undefined ? undefined : join13(slot, newest);
25251
+ return newest === undefined ? undefined : join12(slot, newest);
25293
25252
  } catch {
25294
25253
  return;
25295
25254
  }
@@ -25322,7 +25281,7 @@ function readOpenCodeV2CachedPluginVersion(slot) {
25322
25281
  if (!generation)
25323
25282
  return;
25324
25283
  try {
25325
- const pkg = JSON.parse(readFileSync11(getOpenCodePluginPackageJsonPath(generation), "utf-8"));
25284
+ const pkg = JSON.parse(readFileSync10(getOpenCodePluginPackageJsonPath(generation), "utf-8"));
25326
25285
  return typeof pkg.version === "string" ? pkg.version : undefined;
25327
25286
  } catch {
25328
25287
  return;
@@ -25336,7 +25295,7 @@ var init_opencode_plugin_cache = __esm(() => {
25336
25295
  });
25337
25296
 
25338
25297
  // src/commands/doctor-windows-holders.ts
25339
- import { existsSync as existsSync14 } from "node:fs";
25298
+ import { existsSync as existsSync13 } from "node:fs";
25340
25299
  function fileName(path) {
25341
25300
  return path.toLowerCase().replaceAll("\\", "/").split("/").at(-1) ?? "";
25342
25301
  }
@@ -25429,7 +25388,7 @@ function assertWindowsStoresClosed(paths, processes) {
25429
25388
  if (blockers.length)
25430
25389
  throw new Error(`OpenCode, Pi or ck-mc process is running (${blockers.map(({ pid, imageName, commandLine }) => `${imageName ?? commandLine} PID ${pid}`).join(", ")})`);
25431
25390
  for (const path of [...new Set(paths)]) {
25432
- if (!existsSync14(path))
25391
+ if (!existsSync13(path))
25433
25392
  continue;
25434
25393
  let db;
25435
25394
  let locked = false;
@@ -25536,7 +25495,7 @@ var init_doctor_windows_holders = __esm(async () => {
25536
25495
 
25537
25496
  // src/commands/doctor-opencode2-cache.ts
25538
25497
  import { spawnSync as spawnSync3 } from "node:child_process";
25539
- import { existsSync as existsSync15, rmSync as rmSync4 } from "node:fs";
25498
+ import { existsSync as existsSync14, rmSync as rmSync4 } from "node:fs";
25540
25499
  function runLsof(args, spawn) {
25541
25500
  const result = spawn("lsof", args, { encoding: "utf-8", timeout: 15000, windowsHide: true });
25542
25501
  if (result.error)
@@ -25551,7 +25510,7 @@ function probeHostProcessesUsing(targets, spawn = spawnSync3) {
25551
25510
  if (process.platform === "win32") {
25552
25511
  try {
25553
25512
  assertWindowsStoresClosed(targets.files.filter((path) => !/-(?:wal|shm)$/.test(path)), inspectWindowsProcessesSync());
25554
- if (targets.directories.some(existsSync15))
25513
+ if (targets.directories.some(existsSync14))
25555
25514
  return {
25556
25515
  status: "unknown",
25557
25516
  reason: "Windows cannot rule out open files in plugin cache directories"
@@ -25564,8 +25523,8 @@ function probeHostProcessesUsing(targets, spawn = spawnSync3) {
25564
25523
  };
25565
25524
  }
25566
25525
  }
25567
- const files = targets.files.filter((file) => existsSync15(file));
25568
- const directories = targets.directories.filter((directory) => existsSync15(directory));
25526
+ const files = targets.files.filter((file) => existsSync14(file));
25527
+ const directories = targets.directories.filter((directory) => existsSync14(directory));
25569
25528
  const queries = [];
25570
25529
  if (files.length > 0)
25571
25530
  queries.push(["-w", "-t", "--", ...files]);
@@ -25660,9 +25619,9 @@ function checkOpenCodeV2PluginCache(options, deps = {}) {
25660
25619
  const slot = deps.slot ?? getOpenCodeV2PluginCacheSlot(undefined, distTag ?? "latest");
25661
25620
  const tagged = distTag ? { distTag } : {};
25662
25621
  if (options.referencedSpecs !== undefined && !options.referencedSpecs.has(distTag ?? "latest")) {
25663
- return existsSync15(slot) ? { action: "unused", slot, cached: readOpenCodeV2CachedPluginVersion(slot), ...tagged } : { action: "not_found", slot, unused: true, ...tagged };
25622
+ return existsSync14(slot) ? { action: "unused", slot, cached: readOpenCodeV2CachedPluginVersion(slot), ...tagged } : { action: "not_found", slot, unused: true, ...tagged };
25664
25623
  }
25665
- if (!existsSync15(slot))
25624
+ if (!existsSync14(slot))
25666
25625
  return { action: "not_found", slot, ...tagged };
25667
25626
  const cached = readOpenCodeV2CachedPluginVersion(slot);
25668
25627
  const latest = options.latestVersion ?? undefined;
@@ -25801,7 +25760,7 @@ var init_atomic_write = __esm(() => {
25801
25760
  });
25802
25761
 
25803
25762
  // src/lib/jsonc-config.ts
25804
- import { existsSync as existsSync16, readFileSync as readFileSync12 } from "node:fs";
25763
+ import { existsSync as existsSync15, readFileSync as readFileSync11 } from "node:fs";
25805
25764
  function parseErrorLocation(content, error) {
25806
25765
  const lines = content.split(`
25807
25766
  `);
@@ -25817,9 +25776,9 @@ function parseErrorLocation(content, error) {
25817
25776
  return { line: messageLine ? Number.parseInt(messageLine, 10) : 1, column: 1 };
25818
25777
  }
25819
25778
  function readJsoncConfig(path) {
25820
- if (!existsSync16(path))
25779
+ if (!existsSync15(path))
25821
25780
  return { kind: "missing" };
25822
- const content = readFileSync12(path, "utf-8");
25781
+ const content = readFileSync11(path, "utf-8");
25823
25782
  try {
25824
25783
  const rejectedKeyPaths = [];
25825
25784
  const parsed = sanitizeParsedJson(import_comment_json.parse(content), {
@@ -25845,7 +25804,7 @@ function readJsoncConfigForUpdate(path) {
25845
25804
  return result.value;
25846
25805
  }
25847
25806
  function readJsoncTextForEdit(configPath) {
25848
- const raw = readFileSync12(configPath, "utf-8");
25807
+ const raw = readFileSync11(configPath, "utf-8");
25849
25808
  return raw.startsWith(BYTE_ORDER_MARK) ? { bom: BYTE_ORDER_MARK, text: raw.slice(BYTE_ORDER_MARK.length) } : { bom: "", text: raw };
25850
25809
  }
25851
25810
  function assertJsoncConfigsParseable(paths) {
@@ -25934,13 +25893,13 @@ var init_jsonc_config = __esm(() => {
25934
25893
  });
25935
25894
 
25936
25895
  // src/lib/opencode-detect.ts
25937
- import { existsSync as existsSync17, realpathSync as realpathSync3 } from "node:fs";
25896
+ import { existsSync as existsSync16, realpathSync as realpathSync3 } from "node:fs";
25938
25897
  import { homedir as homedir11 } from "node:os";
25939
- import { join as join14 } from "node:path";
25898
+ import { join as join13 } from "node:path";
25940
25899
  function defaultDeps(overrides = {}) {
25941
25900
  const env = overrides.env ?? process.env;
25942
25901
  return {
25943
- exists: overrides.exists ?? existsSync17,
25902
+ exists: overrides.exists ?? existsSync16,
25944
25903
  isExecutable: overrides.isExecutable ?? isExecutableFile,
25945
25904
  home: overrides.home ?? (env.HOME?.trim() || homedir11()),
25946
25905
  platform: overrides.platform ?? process.platform,
@@ -25950,7 +25909,7 @@ function defaultDeps(overrides = {}) {
25950
25909
  };
25951
25910
  }
25952
25911
  function stockCliBinary(d) {
25953
- return d.platform === "win32" ? join14(d.home, ".opencode", "bin", "opencode.exe") : join14(d.home, ".opencode", "bin", "opencode");
25912
+ return d.platform === "win32" ? join13(d.home, ".opencode", "bin", "opencode.exe") : join13(d.home, ".opencode", "bin", "opencode");
25954
25913
  }
25955
25914
  function extraCliCandidates(d) {
25956
25915
  if (d.platform === "win32") {
@@ -25959,25 +25918,25 @@ function extraCliCandidates(d) {
25959
25918
  const userprofile = d.env.USERPROFILE ?? d.home;
25960
25919
  const out = [];
25961
25920
  if (appdata) {
25962
- out.push(join14(appdata, "npm", "opencode.cmd"));
25963
- out.push(join14(appdata, "npm", "opencode.exe"));
25921
+ out.push(join13(appdata, "npm", "opencode.cmd"));
25922
+ out.push(join13(appdata, "npm", "opencode.exe"));
25964
25923
  }
25965
25924
  if (localappdata) {
25966
- out.push(join14(localappdata, "Microsoft", "WinGet", "Links", "opencode.exe"));
25967
- out.push(join14(localappdata, "opencode", "bin", "opencode.exe"));
25925
+ out.push(join13(localappdata, "Microsoft", "WinGet", "Links", "opencode.exe"));
25926
+ out.push(join13(localappdata, "opencode", "bin", "opencode.exe"));
25968
25927
  }
25969
25928
  if (userprofile) {
25970
- out.push(join14(userprofile, "scoop", "shims", "opencode.exe"));
25929
+ out.push(join13(userprofile, "scoop", "shims", "opencode.exe"));
25971
25930
  }
25972
25931
  return out;
25973
25932
  }
25974
25933
  return [
25975
25934
  "/usr/local/bin/opencode",
25976
25935
  "/opt/homebrew/bin/opencode",
25977
- join14(d.home, ".local", "bin", "opencode"),
25978
- join14(d.home, ".local", "share", "mise", "shims", "opencode"),
25979
- join14(d.home, ".asdf", "shims", "opencode"),
25980
- join14(d.home, ".volta", "bin", "opencode")
25936
+ join13(d.home, ".local", "bin", "opencode"),
25937
+ join13(d.home, ".local", "share", "mise", "shims", "opencode"),
25938
+ join13(d.home, ".asdf", "shims", "opencode"),
25939
+ join13(d.home, ".volta", "bin", "opencode")
25981
25940
  ];
25982
25941
  }
25983
25942
  function openChamberCliCandidates(d) {
@@ -25985,8 +25944,8 @@ function openChamberCliCandidates(d) {
25985
25944
  return [];
25986
25945
  const bundled = ["Contents", "Resources", "opencode-cli", "opencode"];
25987
25946
  return [
25988
- join14("/Applications", "OpenChamber.app", ...bundled),
25989
- join14(d.home, "Applications", "OpenChamber.app", ...bundled)
25947
+ join13("/Applications", "OpenChamber.app", ...bundled),
25948
+ join13(d.home, "Applications", "OpenChamber.app", ...bundled)
25990
25949
  ];
25991
25950
  }
25992
25951
  function canonicalPath(d, path) {
@@ -26007,29 +25966,29 @@ function xdgConfigHome(d) {
26007
25966
  const xdg = d.env.XDG_CONFIG_HOME;
26008
25967
  if (xdg && xdg.length > 0)
26009
25968
  return xdg;
26010
- return join14(d.home, ".config");
25969
+ return join13(d.home, ".config");
26011
25970
  }
26012
25971
  function desktopUserDataDir(d, appId) {
26013
25972
  switch (d.platform) {
26014
25973
  case "darwin":
26015
- return join14(d.home, "Library", "Application Support", appId);
25974
+ return join13(d.home, "Library", "Application Support", appId);
26016
25975
  case "win32":
26017
- return join14(d.env.APPDATA ?? join14(d.home, "AppData", "Roaming"), appId);
25976
+ return join13(d.env.APPDATA ?? join13(d.home, "AppData", "Roaming"), appId);
26018
25977
  default:
26019
- return join14(xdgConfigHome(d), appId);
25978
+ return join13(xdgConfigHome(d), appId);
26020
25979
  }
26021
25980
  }
26022
25981
  function desktopAppPaths(d) {
26023
25982
  switch (d.platform) {
26024
25983
  case "darwin":
26025
- return ["/Applications/OpenCode.app", join14(d.home, "Applications", "OpenCode.app")];
25984
+ return ["/Applications/OpenCode.app", join13(d.home, "Applications", "OpenCode.app")];
26026
25985
  case "win32": {
26027
- const localappdata = d.env.LOCALAPPDATA ?? join14(d.home, "AppData", "Local");
26028
- return [join14(localappdata, "Programs", "OpenCode", "OpenCode.exe")];
25986
+ const localappdata = d.env.LOCALAPPDATA ?? join13(d.home, "AppData", "Local");
25987
+ return [join13(localappdata, "Programs", "OpenCode", "OpenCode.exe")];
26029
25988
  }
26030
25989
  default: {
26031
- const dataHome = d.env.XDG_DATA_HOME && d.env.XDG_DATA_HOME.length > 0 ? d.env.XDG_DATA_HOME : join14(d.home, ".local", "share");
26032
- return OPENCODE_DESKTOP_APP_IDS.map((appId) => join14(dataHome, "applications", `${appId}.desktop`));
25990
+ const dataHome = d.env.XDG_DATA_HOME && d.env.XDG_DATA_HOME.length > 0 ? d.env.XDG_DATA_HOME : join13(d.home, ".local", "share");
25991
+ return OPENCODE_DESKTOP_APP_IDS.map((appId) => join13(dataHome, "applications", `${appId}.desktop`));
26033
25992
  }
26034
25993
  }
26035
25994
  }
@@ -26056,7 +26015,7 @@ function detectOpenCodeInstallations(deps) {
26056
26015
  }
26057
26016
  }
26058
26017
  for (const appId of OPENCODE_DESKTOP_APP_IDS) {
26059
- const marker = join14(desktopUserDataDir(d, appId), OPENCODE_DESKTOP_SETTINGS_FILE);
26018
+ const marker = join13(desktopUserDataDir(d, appId), OPENCODE_DESKTOP_SETTINGS_FILE);
26060
26019
  if (d.exists(marker)) {
26061
26020
  addCandidate(installations, seenRealpaths, d, marker, "desktop", "desktop");
26062
26021
  }
@@ -26154,7 +26113,7 @@ var OPENCODE_BINARY_ENV = "MAGIC_CONTEXT_OPENCODE_BINARY", OPENCODE_VERSION_PROB
26154
26113
  var init_opencode_helpers = () => {};
26155
26114
 
26156
26115
  // src/adapters/opencode.ts
26157
- import { existsSync as existsSync18, readFileSync as readFileSync13, statSync as statSync10 } from "node:fs";
26116
+ import { existsSync as existsSync17, readFileSync as readFileSync12, statSync as statSync10 } from "node:fs";
26158
26117
  import { dirname as dirname10, isAbsolute as isAbsolute5, parse as parsePath, resolve as resolve6 } from "node:path";
26159
26118
  import { fileURLToPath as fileURLToPath2 } from "node:url";
26160
26119
 
@@ -26186,7 +26145,7 @@ class OpenCodeAdapter {
26186
26145
  if (paths.opencodeConfigFormat === "none")
26187
26146
  return false;
26188
26147
  try {
26189
- const raw = readFileSync13(paths.opencodeConfig, "utf-8");
26148
+ const raw = readFileSync12(paths.opencodeConfig, "utf-8");
26190
26149
  const cfg = import_comment_json2.parse(raw);
26191
26150
  return readPluginEntries(cfg).some(({ entry }) => matchesPluginEntry(entry, OPENCODE_PLUGIN_NAME));
26192
26151
  } catch {
@@ -26222,7 +26181,7 @@ class OpenCodeAdapter {
26222
26181
  configPath: target
26223
26182
  };
26224
26183
  }
26225
- const raw = readFileSync13(target, "utf-8");
26184
+ const raw = readFileSync12(target, "utf-8");
26226
26185
  const cfg = import_comment_json2.parse(raw);
26227
26186
  if (cfg === null || typeof cfg !== "object") {
26228
26187
  return {
@@ -26297,7 +26256,7 @@ class OpenCodeAdapter {
26297
26256
  };
26298
26257
  }
26299
26258
  try {
26300
- const raw = readFileSync13(target, "utf-8");
26259
+ const raw = readFileSync12(target, "utf-8");
26301
26260
  const cfg = import_comment_json2.parse(raw);
26302
26261
  if (cfg === null || typeof cfg !== "object") {
26303
26262
  return {
@@ -26348,9 +26307,9 @@ class OpenCodeAdapter {
26348
26307
  }
26349
26308
  getPluginCacheInfo() {
26350
26309
  const legacyPath = getOpenCodePluginCacheDir();
26351
- const legacyExists = existsSync18(legacyPath);
26310
+ const legacyExists = existsSync17(legacyPath);
26352
26311
  const slot = getOpenCodeV2PluginCacheSlot();
26353
- const slotExists = existsSync18(slot);
26312
+ const slotExists = existsSync17(slot);
26354
26313
  const caches = [];
26355
26314
  if (legacyExists || !slotExists) {
26356
26315
  caches.push({
@@ -26408,7 +26367,7 @@ class OpenCodeAdapter {
26408
26367
  if (paths.opencodeConfigFormat === "none")
26409
26368
  return "latest";
26410
26369
  try {
26411
- const cfg = import_comment_json2.parse(readFileSync13(paths.opencodeConfig, "utf-8"));
26370
+ const cfg = import_comment_json2.parse(readFileSync12(paths.opencodeConfig, "utf-8"));
26412
26371
  return readConfiguredOpenCodePluginSpec(cfg);
26413
26372
  } catch {
26414
26373
  return "latest";
@@ -26420,10 +26379,10 @@ class OpenCodeAdapter {
26420
26379
  return readOpenCodeV2CachedPluginVersion(slot) ?? null;
26421
26380
  }
26422
26381
  for (const candidate of getOpenCodePluginPackageJsonPaths()) {
26423
- if (!existsSync18(candidate))
26382
+ if (!existsSync17(candidate))
26424
26383
  continue;
26425
26384
  try {
26426
- const raw = readFileSync13(candidate, "utf-8");
26385
+ const raw = readFileSync12(candidate, "utf-8");
26427
26386
  const pkg = JSON.parse(raw);
26428
26387
  if (typeof pkg.version === "string")
26429
26388
  return pkg.version;
@@ -26466,8 +26425,8 @@ function isDevPathPluginEntry(entry, configDir) {
26466
26425
  const root = parsePath(localPath).root;
26467
26426
  while (localPath !== root) {
26468
26427
  const packagePath = resolve6(localPath, "package.json");
26469
- if (existsSync18(packagePath)) {
26470
- const pkg = JSON.parse(readFileSync13(packagePath, "utf8"));
26428
+ if (existsSync17(packagePath)) {
26429
+ const pkg = JSON.parse(readFileSync12(packagePath, "utf8"));
26471
26430
  return pkg.name === OPENCODE_PLUGIN_NAME;
26472
26431
  }
26473
26432
  localPath = dirname10(localPath);
@@ -26487,7 +26446,7 @@ function matchesPluginEntry(entry, pkgName) {
26487
26446
  }
26488
26447
  function ensureDir2(filePath) {
26489
26448
  const dir = dirname10(filePath);
26490
- if (!existsSync18(dir)) {
26449
+ if (!existsSync17(dir)) {
26491
26450
  const { mkdirSync } = __require("node:fs");
26492
26451
  mkdirSync(dir, { recursive: true });
26493
26452
  }
@@ -26508,8 +26467,8 @@ var init_opencode = __esm(async () => {
26508
26467
  });
26509
26468
 
26510
26469
  // src/lib/pi-package-entry.ts
26511
- import { existsSync as existsSync19, readFileSync as readFileSync14 } from "node:fs";
26512
- import { isAbsolute as isAbsolute6, join as join15 } from "node:path";
26470
+ import { existsSync as existsSync18, readFileSync as readFileSync13 } from "node:fs";
26471
+ import { isAbsolute as isAbsolute6, join as join14 } from "node:path";
26513
26472
  function stripNpmPrefix(value) {
26514
26473
  return value.startsWith("npm:") ? value.slice("npm:".length) : value;
26515
26474
  }
@@ -26564,11 +26523,11 @@ function hasPiMagicContextPackage(entries, agentDir = getPiAgentConfigDir()) {
26564
26523
  return entries.some((entry) => isConfiguredPiMagicContextEntry(entry, agentDir));
26565
26524
  }
26566
26525
  function isPiMagicContextPackageDir(dir) {
26567
- const packageJson = join15(dir, "package.json");
26568
- if (!existsSync19(packageJson))
26526
+ const packageJson = join14(dir, "package.json");
26527
+ if (!existsSync18(packageJson))
26569
26528
  return false;
26570
26529
  try {
26571
- const pkg = JSON.parse(readFileSync14(packageJson, "utf-8"));
26530
+ const pkg = JSON.parse(readFileSync13(packageJson, "utf-8"));
26572
26531
  return typeof pkg.name === "string" && pkg.name === PI_MAGIC_CONTEXT_PACKAGE_NAME;
26573
26532
  } catch {
26574
26533
  return false;
@@ -26580,7 +26539,7 @@ function localPiMagicContextPackageDir(entry, agentDir) {
26580
26539
  if (!spec || spec.startsWith("npm:"))
26581
26540
  return null;
26582
26541
  const path = spec.startsWith("file:") ? spec.slice("file:".length) : spec;
26583
- const dir = isAbsolute6(path) ? path : join15(agentDir, path);
26542
+ const dir = isAbsolute6(path) ? path : join14(agentDir, path);
26584
26543
  return isPiMagicContextPackageDir(dir) ? dir : null;
26585
26544
  }
26586
26545
  function isConfiguredPiMagicContextEntry(entry, agentDir) {
@@ -26604,7 +26563,7 @@ var init_pi_package_entry = __esm(() => {
26604
26563
  });
26605
26564
 
26606
26565
  // src/adapters/pi.ts
26607
- import { existsSync as existsSync20 } from "node:fs";
26566
+ import { existsSync as existsSync19 } from "node:fs";
26608
26567
  import { dirname as dirname11 } from "node:path";
26609
26568
 
26610
26569
  class PiAdapter {
@@ -26743,7 +26702,7 @@ function writePiSettings(settings) {
26743
26702
  }
26744
26703
  function ensureDir3(filePath) {
26745
26704
  const dir = dirname11(filePath);
26746
- if (!existsSync20(dir)) {
26705
+ if (!existsSync19(dir)) {
26747
26706
  const { mkdirSync } = __require("node:fs");
26748
26707
  mkdirSync(dir, { recursive: true });
26749
26708
  }
@@ -29851,7 +29810,7 @@ function installCompartmentHistoryVersions(db) {
29851
29810
 
29852
29811
  // ../plugin/src/features/magic-context/memory/project-identity-cache.ts
29853
29812
  import { createHash as createHash4 } from "node:crypto";
29854
- import { promises as fs2, readFileSync as readFileSync15 } from "node:fs";
29813
+ import { promises as fs2, readFileSync as readFileSync14 } from "node:fs";
29855
29814
  import path4 from "node:path";
29856
29815
  function cachePath(directory, storageDir = getMagicContextStorageDir()) {
29857
29816
  const hash = createHash4("sha256").update(projectDirectoryKey(directory)).digest("hex");
@@ -29865,7 +29824,7 @@ function rememberGitIdentity(directory, identity) {
29865
29824
  }
29866
29825
  function readRememberedGitIdentity(directory, storageDir) {
29867
29826
  try {
29868
- const record = JSON.parse(readFileSync15(cachePath(directory, storageDir), "utf8"));
29827
+ const record = JSON.parse(readFileSync14(cachePath(directory, storageDir), "utf8"));
29869
29828
  if (record.directory === projectDirectoryKey(directory) && /^git:[0-9a-f]{7,64}$/.test(record.identity))
29870
29829
  return record.identity;
29871
29830
  } catch {}
@@ -29878,7 +29837,7 @@ var init_project_identity_cache = __esm(() => {
29878
29837
  });
29879
29838
 
29880
29839
  // ../plugin/src/features/magic-context/memory/unborn-head.ts
29881
- import { readFileSync as readFileSync16, realpathSync as realpathSync4, statSync as statSync11 } from "node:fs";
29840
+ import { readFileSync as readFileSync15, realpathSync as realpathSync4, statSync as statSync11 } from "node:fs";
29882
29841
  import path5 from "node:path";
29883
29842
  function errorCode(error) {
29884
29843
  if (error === null || typeof error !== "object" || !("code" in error))
@@ -29888,7 +29847,7 @@ function errorCode(error) {
29888
29847
  }
29889
29848
  function readText(file) {
29890
29849
  try {
29891
- return { ok: true, text: readFileSync16(file, "utf8") };
29850
+ return { ok: true, text: readFileSync15(file, "utf8") };
29892
29851
  } catch (error) {
29893
29852
  return { ok: false, missing: errorCode(error) === "ENOENT" };
29894
29853
  }
@@ -30039,7 +29998,7 @@ var init_unborn_head = __esm(() => {
30039
29998
  // ../plugin/src/features/magic-context/memory/project-identity.ts
30040
29999
  import { execFileSync as execFileSync4 } from "node:child_process";
30041
30000
  import { createHash as createHash5 } from "node:crypto";
30042
- import { existsSync as existsSync21, realpathSync as realpathSync5, statSync as statSync12 } from "node:fs";
30001
+ import { existsSync as existsSync20, realpathSync as realpathSync5, statSync as statSync12 } from "node:fs";
30043
30002
  import { homedir as homedir12 } from "node:os";
30044
30003
  import path6 from "node:path";
30045
30004
  function asError(error) {
@@ -30223,7 +30182,7 @@ function nearestLastKnownGitIdentity(canonical) {
30223
30182
  const cached = lastKnownGitIdentity(current);
30224
30183
  if (cached !== undefined)
30225
30184
  return { identity: cached, source: current };
30226
- if (existsSync21(path6.join(current, ".git")))
30185
+ if (existsSync20(path6.join(current, ".git")))
30227
30186
  break;
30228
30187
  const parent = path6.dirname(current);
30229
30188
  if (parent === current)
@@ -30346,7 +30305,7 @@ function hasGitDir(canonical) {
30346
30305
  function gitRootInAncestorChain(startDirectory) {
30347
30306
  let current = startDirectory;
30348
30307
  while (true) {
30349
- if (existsSync21(path6.join(current, ".git"))) {
30308
+ if (existsSync20(path6.join(current, ".git"))) {
30350
30309
  try {
30351
30310
  return realpathSync5.native(current);
30352
30311
  } catch {
@@ -33818,7 +33777,7 @@ var init_tool_definition_tokens = __esm(() => {
33818
33777
  });
33819
33778
 
33820
33779
  // ../plugin/src/features/magic-context/tool-owner-backfill.ts
33821
- import { existsSync as existsSync22 } from "node:fs";
33780
+ import { existsSync as existsSync21 } from "node:fs";
33822
33781
  function resolveOpencodeDbPath() {
33823
33782
  return resolveOpenCodeDbPath().path;
33824
33783
  }
@@ -33855,7 +33814,7 @@ function runToolOwnerBackfill(db) {
33855
33814
  return result;
33856
33815
  }
33857
33816
  const opencodeDbPath = resolveOpencodeDbPath();
33858
- if (!existsSync22(opencodeDbPath)) {
33817
+ if (!existsSync21(opencodeDbPath)) {
33859
33818
  log(`[backfill] OpenCode DB not found at ${opencodeDbPath} — marking all unbackfilled sessions as skipped. Lazy adoption (defense-in-depth) handles legacy rows at runtime.`);
33860
33819
  markAllUnbackfilledSessionsSkipped(db);
33861
33820
  result.sessionsSkippedNoOcDb = countSessionsByStatus(db, "skipped");
@@ -34612,21 +34571,8 @@ var init_provider_visible_parts = __esm(() => {
34612
34571
  });
34613
34572
 
34614
34573
  // ../plugin/src/hooks/magic-context/todo-view.ts
34615
- var TODO_STATUS_PENDING = "pending", TODO_STATUS_IN_PROGRESS = "in_progress", TODO_STATUS_COMPLETED = "completed", TODO_STATUS_CANCELLED = "cancelled", TODO_PRIORITY_HIGH = "high", TODO_PRIORITY_MEDIUM = "medium", TODO_PRIORITY_LOW = "low", TODO_STATUSES, TODO_PRIORITIES, TODO_STATUS_SET, TODO_PRIORITY_SET, TERMINAL_STATUSES, TITLE_DONE_STATUSES;
34574
+ var TODO_STATUS_COMPLETED = "completed", TODO_STATUS_CANCELLED = "cancelled", TERMINAL_STATUSES, TITLE_DONE_STATUSES;
34616
34575
  var init_todo_view = __esm(() => {
34617
- TODO_STATUSES = [
34618
- TODO_STATUS_PENDING,
34619
- TODO_STATUS_IN_PROGRESS,
34620
- TODO_STATUS_COMPLETED,
34621
- TODO_STATUS_CANCELLED
34622
- ];
34623
- TODO_PRIORITIES = [
34624
- TODO_PRIORITY_HIGH,
34625
- TODO_PRIORITY_MEDIUM,
34626
- TODO_PRIORITY_LOW
34627
- ];
34628
- TODO_STATUS_SET = new Set(TODO_STATUSES);
34629
- TODO_PRIORITY_SET = new Set(TODO_PRIORITIES);
34630
34576
  TERMINAL_STATUSES = new Set([
34631
34577
  TODO_STATUS_COMPLETED,
34632
34578
  TODO_STATUS_CANCELLED
@@ -36716,14 +36662,14 @@ var init_message_time_backfill = __esm(async () => {
36716
36662
 
36717
36663
  // ../plugin/src/features/magic-context/storage-db.ts
36718
36664
  import {
36719
- existsSync as existsSync23,
36665
+ existsSync as existsSync22,
36720
36666
  readdirSync as readdirSync5,
36721
- readFileSync as readFileSync17,
36667
+ readFileSync as readFileSync16,
36722
36668
  rmdirSync,
36723
36669
  statSync as statSync13,
36724
- unlinkSync as unlinkSync3
36670
+ unlinkSync as unlinkSync4
36725
36671
  } from "node:fs";
36726
- import { basename as basename4, dirname as dirname12, join as join16, resolve as resolve7 } from "node:path";
36672
+ import { basename as basename4, dirname as dirname12, join as join15, resolve as resolve7 } from "node:path";
36727
36673
  function ensureSecureStorageDir(dir) {
36728
36674
  ensureStorageDirectorySync(dir);
36729
36675
  }
@@ -36747,14 +36693,14 @@ function resolveDatabasePath(dbPathOverride) {
36747
36693
  return { dbDir: dirname12(dbPathOverride), dbPath: dbPathOverride };
36748
36694
  }
36749
36695
  const dbDir = getMagicContextStorageDir();
36750
- return { dbDir, dbPath: join16(dbDir, "context.db") };
36696
+ return { dbDir, dbPath: join15(dbDir, "context.db") };
36751
36697
  }
36752
36698
  function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
36753
- if (existsSync23(targetDbPath))
36699
+ if (existsSync22(targetDbPath))
36754
36700
  return;
36755
36701
  const legacyDir = getLegacyOpenCodeMagicContextStorageDir();
36756
- const legacyDbPath = join16(legacyDir, "context.db");
36757
- if (!existsSync23(legacyDbPath))
36702
+ const legacyDbPath = join15(legacyDir, "context.db");
36703
+ if (!existsSync22(legacyDbPath))
36758
36704
  return;
36759
36705
  log(`[magic-context] migrating legacy plugin storage: ${legacyDir} -> ${targetDbDir} (legacy left in place as backup)`);
36760
36706
  ensureSecureStorageDir(targetDbDir);
@@ -36771,8 +36717,8 @@ function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
36771
36717
  }
36772
36718
  for (const suffix of ["", "-wal", "-shm"]) {
36773
36719
  const src = `${legacyDbPath}${suffix}`;
36774
- const dst = join16(targetDbDir, `context.db${suffix}`);
36775
- if (existsSync23(src)) {
36720
+ const dst = join15(targetDbDir, `context.db${suffix}`);
36721
+ if (existsSync22(src)) {
36776
36722
  try {
36777
36723
  copyStorageFileSync(src, dst);
36778
36724
  } catch (error) {
@@ -36780,9 +36726,9 @@ function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
36780
36726
  }
36781
36727
  }
36782
36728
  }
36783
- const legacyModelsDir = join16(legacyDir, "models");
36784
- const targetModelsDir = join16(targetDbDir, "models");
36785
- if (existsSync23(legacyModelsDir) && !existsSync23(targetModelsDir)) {
36729
+ const legacyModelsDir = join15(legacyDir, "models");
36730
+ const targetModelsDir = join15(targetDbDir, "models");
36731
+ if (existsSync22(legacyModelsDir) && !existsSync22(targetModelsDir)) {
36786
36732
  try {
36787
36733
  copyStorageTreeSync(legacyModelsDir, targetModelsDir);
36788
36734
  } catch (error) {
@@ -36890,7 +36836,7 @@ function classifyJunkDiscovery(portFile, raw, staleFiles) {
36890
36836
  function inspectRpcServerDiscovery(storageDir, processes, options) {
36891
36837
  const deadline = options?.deadlineMs === undefined ? Number.POSITIVE_INFINITY : Date.now() + options.deadlineMs;
36892
36838
  let progressAt = Date.now() + 3000;
36893
- const rpcRoot = join16(storageDir, "rpc");
36839
+ const rpcRoot = join15(storageDir, "rpc");
36894
36840
  let projectEntries;
36895
36841
  try {
36896
36842
  projectEntries = rpcDiscoveryFs.readdirSync(rpcRoot, { withFileTypes: true });
@@ -36904,7 +36850,7 @@ function inspectRpcServerDiscovery(storageDir, processes, options) {
36904
36850
  for (const projectEntry of projectEntries) {
36905
36851
  if (!projectEntry.isDirectory())
36906
36852
  continue;
36907
- const projectDir = join16(rpcRoot, projectEntry.name);
36853
+ const projectDir = join15(rpcRoot, projectEntry.name);
36908
36854
  let entries;
36909
36855
  try {
36910
36856
  entries = rpcDiscoveryFs.readdirSync(projectDir);
@@ -36915,7 +36861,7 @@ function inspectRpcServerDiscovery(storageDir, processes, options) {
36915
36861
  }
36916
36862
  for (const entry of entries) {
36917
36863
  if (entry === "port" || entry.startsWith("port-") && entry.endsWith(".json")) {
36918
- portFiles.push(join16(projectDir, entry));
36864
+ portFiles.push(join15(projectDir, entry));
36919
36865
  }
36920
36866
  }
36921
36867
  }
@@ -37018,7 +36964,7 @@ function inspectRpcServerDiscovery(storageDir, processes, options) {
37018
36964
  return { state: "stale", serverPids: [], staleFiles };
37019
36965
  }
37020
36966
  function pruneEmptyRpcDiscoveryDirs(storageDir) {
37021
- const rpcRoot = join16(storageDir, "rpc");
36967
+ const rpcRoot = join15(storageDir, "rpc");
37022
36968
  let entries;
37023
36969
  try {
37024
36970
  entries = rpcDiscoveryFs.readdirSync(rpcRoot, { withFileTypes: true });
@@ -37030,7 +36976,7 @@ function pruneEmptyRpcDiscoveryDirs(storageDir) {
37030
36976
  for (const entry of entries) {
37031
36977
  if (!entry.isDirectory())
37032
36978
  continue;
37033
- const projectDir = join16(rpcRoot, entry.name);
36979
+ const projectDir = join15(rpcRoot, entry.name);
37034
36980
  try {
37035
36981
  if (rpcDiscoveryFs.readdirSync(projectDir).length > 0)
37036
36982
  continue;
@@ -37044,7 +36990,7 @@ function pruneEmptyRpcDiscoveryDirs(storageDir) {
37044
36990
  return removed;
37045
36991
  }
37046
36992
  function removeRpcDiscoveryRecords(storageDir, files) {
37047
- const rpcRoot = resolve7(join16(storageDir, "rpc"));
36993
+ const rpcRoot = resolve7(join15(storageDir, "rpc"));
37048
36994
  const removed = [];
37049
36995
  const failed = [];
37050
36996
  for (const file of files) {
@@ -37096,7 +37042,7 @@ function isDefaultSharedDatabasePath(dbPath) {
37096
37042
  if (!process.env.XDG_DATA_HOME && (process.env.MAGIC_CONTEXT_TEST_DATA_DIR || false)) {
37097
37043
  return false;
37098
37044
  }
37099
- return resolve7(dbPath) === resolve7(join16(getMagicContextStorageDir(), "context.db"));
37045
+ return resolve7(dbPath) === resolve7(join15(getMagicContextStorageDir(), "context.db"));
37100
37046
  }
37101
37047
  function migrationBlockingPiPids(dbPath, discovery, discoveredPiPids) {
37102
37048
  if (isDefaultSharedDatabasePath(dbPath))
@@ -38512,7 +38458,7 @@ function openDatabase(dbPathOrOptions) {
38512
38458
  }
38513
38459
  ensureSecureStorageDir(dbDir);
38514
38460
  tightenStorageTree(dbDir);
38515
- if (!existsSync23(dbPath) && shouldEnforcePrivateStoragePermissions()) {
38461
+ if (!existsSync22(dbPath) && shouldEnforcePrivateStoragePermissions()) {
38516
38462
  try {
38517
38463
  writeStorageFileSync(dbPath, new Uint8Array, { flag: "wx" });
38518
38464
  } catch (error) {
@@ -38614,9 +38560,9 @@ var init_storage_db = __esm(async () => {
38614
38560
  RPC_DISCOVERY_PARSE_GRACE_MS = 10 * 60 * 1000;
38615
38561
  defaultRpcDiscoveryFs = {
38616
38562
  readdirSync: (path, options) => options?.withFileTypes ? readdirSync5(path, { withFileTypes: true }) : readdirSync5(path),
38617
- readFileSync: (path, encoding) => String(readFileSync17(path, encoding)),
38563
+ readFileSync: (path, encoding) => String(readFileSync16(path, encoding)),
38618
38564
  statSync: (path) => ({ mtimeMs: statSync13(path).mtimeMs }),
38619
- unlinkSync: (path) => unlinkSync3(path),
38565
+ unlinkSync: (path) => unlinkSync4(path),
38620
38566
  rmdirSync: (path) => rmdirSync(path)
38621
38567
  };
38622
38568
  rpcDiscoveryFs = defaultRpcDiscoveryFs;
@@ -38629,18 +38575,18 @@ var init_storage_db = __esm(async () => {
38629
38575
  });
38630
38576
 
38631
38577
  // src/lib/database-access.ts
38632
- import { existsSync as existsSync24, rmSync as rmSync6 } from "node:fs";
38578
+ import { existsSync as existsSync23, rmSync as rmSync6 } from "node:fs";
38633
38579
  import { basename as basename5, dirname as dirname13 } from "node:path";
38634
38580
  import { pathToFileURL as pathToFileURL2 } from "node:url";
38635
38581
  function getPersistedSchemaVersion2(db) {
38636
38582
  return getPersistedSchemaVersion(db);
38637
38583
  }
38638
38584
  function openExistingDatabase(path, options) {
38639
- if (!existsSync24(path))
38585
+ if (!existsSync23(path))
38640
38586
  return null;
38641
38587
  if (options.readonly) {
38642
38588
  const name = basename5(path);
38643
- if ((name === "context.db" || name === "store.db") && !existsSync24(`${path}-wal`) && !existsSync24(`${path}-shm`)) {
38589
+ if ((name === "context.db" || name === "store.db") && !existsSync23(`${path}-wal`) && !existsSync23(`${path}-shm`)) {
38644
38590
  const probe = probeHostProcessesUsing({
38645
38591
  files: [path, `${path}-wal`, `${path}-shm`],
38646
38592
  directories: []
@@ -38706,7 +38652,7 @@ async function backupDatabaseSnapshot(db, sourcePath, destination) {
38706
38652
  if (typeof sqlite.backup !== "function") {
38707
38653
  throw new Error("The active SQLite runtime does not provide a snapshot backup API");
38708
38654
  }
38709
- if (existsSync24(destination)) {
38655
+ if (existsSync23(destination)) {
38710
38656
  throw new Error(`Refusing to overwrite existing backup ${destination}`);
38711
38657
  }
38712
38658
  const reader = openExistingDatabase(sourcePath, { readonly: true });
@@ -39007,10 +38953,10 @@ var init_dreamer_setup = __esm(() => {
39007
38953
  });
39008
38954
 
39009
38955
  // src/commands/setup-pi.ts
39010
- import { existsSync as existsSync25, mkdirSync as mkdirSync6 } from "node:fs";
38956
+ import { existsSync as existsSync24, mkdirSync as mkdirSync6 } from "node:fs";
39011
38957
  import { dirname as dirname14 } from "node:path";
39012
38958
  function ensureDir4(path) {
39013
- if (!existsSync25(path))
38959
+ if (!existsSync24(path))
39014
38960
  mkdirSync6(path, { recursive: true });
39015
38961
  }
39016
38962
  async function getDefaultPrompts() {
@@ -39466,15 +39412,15 @@ var init_setup_omp = __esm(() => {
39466
39412
 
39467
39413
  // ../plugin/src/shared/opencode-config-dir.ts
39468
39414
  import { homedir as homedir13 } from "node:os";
39469
- import { join as join17, resolve as resolve8 } from "node:path";
39415
+ import { join as join16, resolve as resolve8 } from "node:path";
39470
39416
  function resolveHomeDir() {
39471
39417
  return process.env.HOME?.trim() || homedir13();
39472
39418
  }
39473
39419
  function getOpenCodeGlobalConfigDir() {
39474
39420
  if (process.platform === "win32") {
39475
- return join17(resolveHomeDir(), ".config", "opencode");
39421
+ return join16(resolveHomeDir(), ".config", "opencode");
39476
39422
  }
39477
- return join17(process.env.XDG_CONFIG_HOME || join17(resolveHomeDir(), ".config"), "opencode");
39423
+ return join16(process.env.XDG_CONFIG_HOME || join16(resolveHomeDir(), ".config"), "opencode");
39478
39424
  }
39479
39425
  function getEnvConfigDir() {
39480
39426
  const envConfigDir = process.env.OPENCODE_CONFIG_DIR?.trim();
@@ -39490,14 +39436,14 @@ function getOpenCodeConfigPaths(options) {
39490
39436
  const configDir = getOpenCodeConfigDir2(options);
39491
39437
  return {
39492
39438
  configDir,
39493
- configJson: join17(configDir, "opencode.json"),
39494
- configJsonc: join17(configDir, "opencode.jsonc"),
39495
- packageJson: join17(configDir, "package.json"),
39496
- omoConfig: join17(configDir, "magic-context.jsonc")
39439
+ configJson: join16(configDir, "opencode.json"),
39440
+ configJsonc: join16(configDir, "opencode.jsonc"),
39441
+ packageJson: join16(configDir, "package.json"),
39442
+ omoConfig: join16(configDir, "magic-context.jsonc")
39497
39443
  };
39498
39444
  }
39499
39445
  function getOpenCodeConfigDirs() {
39500
- const dirs = [getOpenCodeGlobalConfigDir(), join17(resolveHomeDir(), ".opencode")];
39446
+ const dirs = [getOpenCodeGlobalConfigDir(), join16(resolveHomeDir(), ".opencode")];
39501
39447
  const envDir = getEnvConfigDir();
39502
39448
  if (envDir)
39503
39449
  dirs.push(envDir);
@@ -39507,7 +39453,7 @@ var init_opencode_config_dir = () => {};
39507
39453
 
39508
39454
  // ../plugin/src/shared/conflict-detector.ts
39509
39455
  import { homedir as homedir14 } from "node:os";
39510
- import { join as join18 } from "node:path";
39456
+ import { join as join17 } from "node:path";
39511
39457
  function detectConflicts(directory, options) {
39512
39458
  const compactionEnabled = options?.compactionEnabled ?? true;
39513
39459
  const hostGeneration = options?.hostGeneration ?? "v1";
@@ -39574,19 +39520,19 @@ function checkCompaction(directory, hostGeneration) {
39574
39520
  function openCodeConfigFileChain(directory, hostGeneration) {
39575
39521
  const globalDir = getOpenCodeGlobalConfigDir();
39576
39522
  const wellKnown = [
39577
- join18(globalDir, "config.json"),
39578
- join18(globalDir, "opencode.json"),
39579
- join18(globalDir, "opencode.jsonc")
39523
+ join17(globalDir, "config.json"),
39524
+ join17(globalDir, "opencode.json"),
39525
+ join17(globalDir, "opencode.jsonc")
39580
39526
  ];
39581
- const globalSupplementary = getOpenCodeConfigDirs().filter((dir) => dir !== globalDir).flatMap((dir) => [join18(dir, "opencode.json"), join18(dir, "opencode.jsonc")]);
39527
+ const globalSupplementary = getOpenCodeConfigDirs().filter((dir) => dir !== globalDir).flatMap((dir) => [join17(dir, "opencode.json"), join17(dir, "opencode.jsonc")]);
39582
39528
  const explicitConfig = process.env.OPENCODE_CONFIG?.trim();
39583
39529
  const explicit = explicitConfig ? [explicitConfig] : [];
39584
39530
  const disableProjectConfig = process.env.OPENCODE_DISABLE_PROJECT_CONFIG?.toLowerCase();
39585
39531
  const skipProject = hostGeneration === "v1" && (disableProjectConfig === "true" || disableProjectConfig === "1");
39586
- const direct = skipProject ? [] : [join18(directory, "opencode.json"), join18(directory, "opencode.jsonc")];
39532
+ const direct = skipProject ? [] : [join17(directory, "opencode.json"), join17(directory, "opencode.jsonc")];
39587
39533
  const projectSupplementary = skipProject ? [] : [
39588
- join18(directory, ".opencode", "opencode.json"),
39589
- join18(directory, ".opencode", "opencode.jsonc")
39534
+ join17(directory, ".opencode", "opencode.json"),
39535
+ join17(directory, ".opencode", "opencode.jsonc")
39590
39536
  ];
39591
39537
  const files = hostGeneration === "v2" ? [
39592
39538
  ...wellKnown,
@@ -39673,10 +39619,10 @@ function collectPluginEntries(directory) {
39673
39619
  }
39674
39620
  };
39675
39621
  for (const configPath of [
39676
- join18(directory, ".opencode", "opencode.jsonc"),
39677
- join18(directory, ".opencode", "opencode.json"),
39678
- join18(directory, "opencode.jsonc"),
39679
- join18(directory, "opencode.json")
39622
+ join17(directory, ".opencode", "opencode.jsonc"),
39623
+ join17(directory, ".opencode", "opencode.json"),
39624
+ join17(directory, "opencode.jsonc"),
39625
+ join17(directory, "opencode.json")
39680
39626
  ]) {
39681
39627
  const config = readJsoncFile(configPath);
39682
39628
  pushFrom(config?.plugin);
@@ -39686,7 +39632,7 @@ function collectPluginEntries(directory) {
39686
39632
  for (const dir of getOpenCodeConfigDirs()) {
39687
39633
  const names = dir === globalDir ? ["config.json", "opencode.json", "opencode.jsonc"] : ["opencode.json", "opencode.jsonc"];
39688
39634
  for (const name of names) {
39689
- const config = readJsoncFile(join18(dir, name));
39635
+ const config = readJsoncFile(join17(dir, name));
39690
39636
  pushFrom(config?.plugin);
39691
39637
  }
39692
39638
  }
@@ -39720,7 +39666,7 @@ function readOmoDisabledHooks(directory) {
39720
39666
  try {
39721
39667
  for (const dir of getOpenCodeConfigDirs()) {
39722
39668
  for (const name of configNames) {
39723
- const config = readJsoncFile(join18(dir, name));
39669
+ const config = readJsoncFile(join17(dir, name));
39724
39670
  if (config?.disabled_hooks) {
39725
39671
  for (const hook of config.disabled_hooks) {
39726
39672
  disabled.add(hook);
@@ -39730,7 +39676,7 @@ function readOmoDisabledHooks(directory) {
39730
39676
  }
39731
39677
  } catch {}
39732
39678
  for (const name of configNames) {
39733
- const config = readJsoncFile(join18(directory, name));
39679
+ const config = readJsoncFile(join17(directory, name));
39734
39680
  if (config?.disabled_hooks) {
39735
39681
  for (const hook of config.disabled_hooks) {
39736
39682
  disabled.add(hook);
@@ -39738,9 +39684,9 @@ function readOmoDisabledHooks(directory) {
39738
39684
  }
39739
39685
  }
39740
39686
  const homeDir = process.env.HOME || homedir14();
39741
- const omoHomeDir = join18(homeDir, ".omo");
39687
+ const omoHomeDir = join17(homeDir, ".omo");
39742
39688
  for (const name of ["omo.jsonc", "omo.json"]) {
39743
- const config = readJsoncFile(join18(omoHomeDir, name));
39689
+ const config = readJsoncFile(join17(omoHomeDir, name));
39744
39690
  if (config?.["[opencode]"]?.disabled_hooks) {
39745
39691
  for (const hook of config["[opencode]"].disabled_hooks) {
39746
39692
  disabled.add(hook);
@@ -39748,7 +39694,7 @@ function readOmoDisabledHooks(directory) {
39748
39694
  }
39749
39695
  }
39750
39696
  for (const name of ["omo.jsonc", "omo.json"]) {
39751
- const config = readJsoncFile(join18(directory, ".omo", name));
39697
+ const config = readJsoncFile(join17(directory, ".omo", name));
39752
39698
  if (config?.["[opencode]"]?.disabled_hooks) {
39753
39699
  for (const hook of config["[opencode]"].disabled_hooks) {
39754
39700
  disabled.add(hook);
@@ -39767,9 +39713,9 @@ var init_conflict_detector = __esm(() => {
39767
39713
  });
39768
39714
 
39769
39715
  // ../plugin/src/shared/conflict-fixer.ts
39770
- import { existsSync as existsSync26, readFileSync as readFileSync18, writeFileSync as writeFileSync6 } from "node:fs";
39716
+ import { existsSync as existsSync25, readFileSync as readFileSync17, writeFileSync as writeFileSync6 } from "node:fs";
39771
39717
  import { homedir as homedir15 } from "node:os";
39772
- import { join as join19 } from "node:path";
39718
+ import { join as join18 } from "node:path";
39773
39719
  function isRecord3(value) {
39774
39720
  return typeof value === "object" && value !== null && !Array.isArray(value);
39775
39721
  }
@@ -39777,11 +39723,11 @@ function asStringArray(value) {
39777
39723
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
39778
39724
  }
39779
39725
  function readConfig(filePath) {
39780
- if (!existsSync26(filePath)) {
39726
+ if (!existsSync25(filePath)) {
39781
39727
  return null;
39782
39728
  }
39783
39729
  try {
39784
- const text = readFileSync18(filePath, "utf-8");
39730
+ const text = readFileSync17(filePath, "utf-8");
39785
39731
  const parsed = import_comment_json5.parse(text);
39786
39732
  return isRecord3(parsed) ? { config: parsed, text } : null;
39787
39733
  } catch {
@@ -39793,23 +39739,23 @@ function writeConfig(filePath, text) {
39793
39739
  }
39794
39740
  function resolveUserOpenCodeConfigPath() {
39795
39741
  const paths = getOpenCodeConfigPaths({ binary: "opencode" });
39796
- if (existsSync26(paths.configJsonc))
39742
+ if (existsSync25(paths.configJsonc))
39797
39743
  return paths.configJsonc;
39798
39744
  return paths.configJson;
39799
39745
  }
39800
39746
  function collectOpenCodeConfigPaths(directory) {
39801
39747
  const paths = new Set;
39802
39748
  const userConfig = resolveUserOpenCodeConfigPath();
39803
- if (existsSync26(userConfig)) {
39749
+ if (existsSync25(userConfig)) {
39804
39750
  paths.add(userConfig);
39805
39751
  }
39806
39752
  for (const filePath of [
39807
- join19(directory, ".opencode", "opencode.jsonc"),
39808
- join19(directory, ".opencode", "opencode.json"),
39809
- join19(directory, "opencode.jsonc"),
39810
- join19(directory, "opencode.json")
39753
+ join18(directory, ".opencode", "opencode.jsonc"),
39754
+ join18(directory, ".opencode", "opencode.json"),
39755
+ join18(directory, "opencode.jsonc"),
39756
+ join18(directory, "opencode.json")
39811
39757
  ]) {
39812
- if (existsSync26(filePath)) {
39758
+ if (existsSync25(filePath)) {
39813
39759
  paths.add(filePath);
39814
39760
  }
39815
39761
  }
@@ -39819,26 +39765,26 @@ function collectOmoConfigPaths(directory) {
39819
39765
  const paths = new Set;
39820
39766
  const configDir = getOpenCodeConfigPaths({ binary: "opencode" }).configDir;
39821
39767
  for (const fileName of OMO_CONFIG_NAMES) {
39822
- const userPath = join19(configDir, fileName);
39823
- const projectPath = join19(directory, fileName);
39824
- if (existsSync26(userPath)) {
39768
+ const userPath = join18(configDir, fileName);
39769
+ const projectPath = join18(directory, fileName);
39770
+ if (existsSync25(userPath)) {
39825
39771
  paths.add(userPath);
39826
39772
  }
39827
- if (existsSync26(projectPath)) {
39773
+ if (existsSync25(projectPath)) {
39828
39774
  paths.add(projectPath);
39829
39775
  }
39830
39776
  }
39831
39777
  const homeDir = process.env.HOME || homedir15();
39832
- const omoHomeDir = join19(homeDir, ".omo");
39778
+ const omoHomeDir = join18(homeDir, ".omo");
39833
39779
  for (const name of OMO_UNIFIED_NAMES) {
39834
- const userPath = join19(omoHomeDir, name);
39835
- if (existsSync26(userPath)) {
39780
+ const userPath = join18(omoHomeDir, name);
39781
+ if (existsSync25(userPath)) {
39836
39782
  paths.add(userPath);
39837
39783
  }
39838
39784
  }
39839
39785
  for (const name of OMO_UNIFIED_NAMES) {
39840
- const projectPath = join19(directory, ".omo", name);
39841
- if (existsSync26(projectPath)) {
39786
+ const projectPath = join18(directory, ".omo", name);
39787
+ if (existsSync25(projectPath)) {
39842
39788
  paths.add(projectPath);
39843
39789
  }
39844
39790
  }
@@ -39966,7 +39912,7 @@ var init_conflict_fixer = __esm(() => {
39966
39912
  });
39967
39913
 
39968
39914
  // src/commands/setup-opencode.ts
39969
- import { existsSync as existsSync27 } from "node:fs";
39915
+ import { existsSync as existsSync26 } from "node:fs";
39970
39916
  import { basename as basename6, dirname as dirname15 } from "node:path";
39971
39917
  function resolveCompactionEnabledForWriter() {
39972
39918
  try {
@@ -39982,7 +39928,7 @@ function isPlainObject5(value) {
39982
39928
  }
39983
39929
  function planOpenCodeConfigUpdate(configPath, removeDcp = false, compactionEnabled = true, hostGeneration = "v1") {
39984
39930
  const registrationKey = pluginConfigKeyFor(hostGeneration);
39985
- const existsAtCommit = existsSync27(configPath);
39931
+ const existsAtCommit = existsSync26(configPath);
39986
39932
  const existing = existsAtCommit ? readJsoncConfigForUpdate(configPath) : {};
39987
39933
  if (!existsAtCommit) {
39988
39934
  const created = { [registrationKey]: [OPENCODE_PLUGIN_ENTRY_WITH_VERSION] };
@@ -40038,7 +39984,7 @@ function planOpenCodeConfigUpdate(configPath, removeDcp = false, compactionEnabl
40038
39984
  return changed ? document.bom + text : null;
40039
39985
  }
40040
39986
  function planTuiConfigUpdate(configPath) {
40041
- const existsAtCommit = existsSync27(configPath);
39987
+ const existsAtCommit = existsSync26(configPath);
40042
39988
  const existing = existsAtCommit ? readJsoncConfigForUpdate(configPath) : {};
40043
39989
  if (!existsAtCommit) {
40044
39990
  return `${import_comment_json6.stringify({ plugin: [OPENCODE_PLUGIN_ENTRY_WITH_VERSION] }, null, 2)}
@@ -40165,7 +40111,7 @@ async function runSetup3(dryRun = false) {
40165
40111
  log3.warn("You can configure models manually in magic-context.jsonc later");
40166
40112
  }
40167
40113
  const paths = detectConfigPaths();
40168
- const hadExistingSetup = paths.opencodeConfigFormat !== "none" || existsSync27(paths.magicContextConfig) || paths.tuiConfigFormat !== "none";
40114
+ const hadExistingSetup = paths.opencodeConfigFormat !== "none" || existsSync26(paths.magicContextConfig) || paths.tuiConfigFormat !== "none";
40169
40115
  if (!dryRun) {
40170
40116
  try {
40171
40117
  assertJsoncConfigsParseable([
@@ -40392,12 +40338,6 @@ async function runSetup4(argv) {
40392
40338
  continue;
40393
40339
  }
40394
40340
  if (!dryRun) {
40395
- const ignore = ensureDocsProposalGitignore(process.cwd());
40396
- if (ignore.status === "added") {
40397
- log3.info(`Added .cortexkit/magic-context/ to ${ignore.path}`);
40398
- } else if (ignore.status === "failed") {
40399
- log3.warn(`Could not update ${ignore.path}: ${ignore.error}`);
40400
- }
40401
40341
  printNextSteps(adapter);
40402
40342
  }
40403
40343
  }
@@ -40446,7 +40386,6 @@ function printNextSteps(adapter) {
40446
40386
  }
40447
40387
  var init_setup = __esm(async () => {
40448
40388
  init_dashboard_install();
40449
- init_docs_proposal_gitignore();
40450
40389
  init_prompts();
40451
40390
  init_setup_omp();
40452
40391
  init_setup_pi();
@@ -40458,7 +40397,7 @@ var init_setup = __esm(async () => {
40458
40397
  });
40459
40398
 
40460
40399
  // src/lib/disk-space.ts
40461
- import { existsSync as existsSync28, statfsSync, statSync as statSync14 } from "node:fs";
40400
+ import { existsSync as existsSync27, statfsSync, statSync as statSync14 } from "node:fs";
40462
40401
  import { dirname as dirname16, resolve as resolve9 } from "node:path";
40463
40402
  function availableDiskBytes(path) {
40464
40403
  const filesystem = statfsSync(path);
@@ -40476,7 +40415,7 @@ function checkDiskSpace(path, bytes, freeBytes) {
40476
40415
  function existingDirectoryAncestor(path) {
40477
40416
  let current = resolve9(path);
40478
40417
  for (;; ) {
40479
- if (existsSync28(current) && statSync14(current).isDirectory())
40418
+ if (existsSync27(current) && statSync14(current).isDirectory())
40480
40419
  return current;
40481
40420
  const parent = dirname16(current);
40482
40421
  if (parent === current)
@@ -40488,24 +40427,24 @@ var init_disk_space = () => {};
40488
40427
 
40489
40428
  // ../plugin/src/hooks/auto-update-checker/constants.ts
40490
40429
  import { homedir as homedir16, platform } from "node:os";
40491
- import { join as join20 } from "node:path";
40430
+ import { join as join19 } from "node:path";
40492
40431
  function getOpenCodeCacheRoot() {
40493
40432
  if (platform() === "win32") {
40494
- return join20(process.env.LOCALAPPDATA ?? homedir16(), "opencode");
40433
+ return join19(process.env.LOCALAPPDATA ?? homedir16(), "opencode");
40495
40434
  }
40496
- return join20(homedir16(), ".cache", "opencode");
40435
+ return join19(homedir16(), ".cache", "opencode");
40497
40436
  }
40498
40437
  function getOpenCodeConfigRoot() {
40499
40438
  if (platform() === "win32") {
40500
- return join20(process.env.APPDATA ?? join20(homedir16(), "AppData", "Roaming"), "opencode");
40439
+ return join19(process.env.APPDATA ?? join19(homedir16(), "AppData", "Roaming"), "opencode");
40501
40440
  }
40502
- return join20(process.env.XDG_CONFIG_HOME ?? join20(homedir16(), ".config"), "opencode");
40441
+ return join19(process.env.XDG_CONFIG_HOME ?? join19(homedir16(), ".config"), "opencode");
40503
40442
  }
40504
40443
  var PACKAGE_NAME = "@cortexkit/opencode-magic-context", CACHE_DIR, USER_OPENCODE_CONFIG, USER_OPENCODE_CONFIG_JSONC;
40505
40444
  var init_constants2 = __esm(() => {
40506
- CACHE_DIR = join20(getOpenCodeCacheRoot(), "packages");
40507
- USER_OPENCODE_CONFIG = join20(getOpenCodeConfigRoot(), "opencode.json");
40508
- USER_OPENCODE_CONFIG_JSONC = join20(getOpenCodeConfigRoot(), "opencode.jsonc");
40445
+ CACHE_DIR = join19(getOpenCodeCacheRoot(), "packages");
40446
+ USER_OPENCODE_CONFIG = join19(getOpenCodeConfigRoot(), "opencode.json");
40447
+ USER_OPENCODE_CONFIG_JSONC = join19(getOpenCodeConfigRoot(), "opencode.jsonc");
40509
40448
  });
40510
40449
 
40511
40450
  // ../plugin/src/hooks/auto-update-checker/types.ts
@@ -40529,14 +40468,14 @@ var init_types = __esm(() => {
40529
40468
  // ../plugin/src/hooks/auto-update-checker/checker.ts
40530
40469
  import {
40531
40470
  accessSync as accessSync3,
40532
- existsSync as existsSync29,
40471
+ existsSync as existsSync28,
40533
40472
  constants as fsConstants,
40534
- readFileSync as readFileSync19,
40473
+ readFileSync as readFileSync18,
40535
40474
  renameSync as renameSync5,
40536
40475
  statSync as statSync15,
40537
40476
  writeFileSync as writeFileSync7
40538
40477
  } from "node:fs";
40539
- import { dirname as dirname17, isAbsolute as isAbsolute7, join as join21, resolve as resolve10 } from "node:path";
40478
+ import { dirname as dirname17, isAbsolute as isAbsolute7, join as join20, resolve as resolve10 } from "node:path";
40540
40479
  function warn(message) {
40541
40480
  log(`WARN: ${message}`);
40542
40481
  }
@@ -40566,13 +40505,13 @@ function getSurfaceConfigPaths(directory, surface) {
40566
40505
  const dirs = [
40567
40506
  globalDir,
40568
40507
  directory,
40569
- join21(directory, ".opencode"),
40508
+ join20(directory, ".opencode"),
40570
40509
  process.env.OPENCODE_CONFIG_DIR
40571
40510
  ].filter((value) => Boolean(value));
40572
40511
  const paths = [];
40573
40512
  for (const dir of dirs) {
40574
40513
  for (const extension of ["json", "jsonc"]) {
40575
- const path = join21(dir, `${name}.${extension}`);
40514
+ const path = join20(dir, `${name}.${extension}`);
40576
40515
  if (!paths.includes(path))
40577
40516
  paths.push(path);
40578
40517
  }
@@ -40583,9 +40522,9 @@ function getWinningConfig(directory, surface) {
40583
40522
  let winner = null;
40584
40523
  for (const path of getSurfaceConfigPaths(directory, surface)) {
40585
40524
  try {
40586
- if (!existsSync29(path))
40525
+ if (!existsSync28(path))
40587
40526
  continue;
40588
- const parsed = parseJsonConfig(readFileSync19(path, "utf-8"));
40527
+ const parsed = parseJsonConfig(readFileSync18(path, "utf-8"));
40589
40528
  const entries = getPluginEntries(parsed);
40590
40529
  if (entries.some((entry) => entry === PACKAGE_NAME || entry.startsWith(`${PACKAGE_NAME}@`))) {
40591
40530
  if (winner) {
@@ -40622,14 +40561,14 @@ var init_checker = __esm(async () => {
40622
40561
  });
40623
40562
 
40624
40563
  // src/lib/opencode-plugin-schema-fence.ts
40625
- import { existsSync as existsSync30, readdirSync as readdirSync6, readFileSync as readFileSync20 } from "node:fs";
40626
- import { join as join22 } from "node:path";
40564
+ import { existsSync as existsSync29, readdirSync as readdirSync6, readFileSync as readFileSync19 } from "node:fs";
40565
+ import { join as join21 } from "node:path";
40627
40566
  import { gunzipSync as gunzipSync2 } from "node:zlib";
40628
40567
  function readPackageVersion(packageJsonPath) {
40629
40568
  try {
40630
- if (!existsSync30(packageJsonPath))
40569
+ if (!existsSync29(packageJsonPath))
40631
40570
  return null;
40632
- const packageJson = JSON.parse(readFileSync20(packageJsonPath, "utf-8"));
40571
+ const packageJson = JSON.parse(readFileSync19(packageJsonPath, "utf-8"));
40633
40572
  if (packageJson.name !== OPENCODE_PLUGIN_NAME || typeof packageJson.version !== "string") {
40634
40573
  return null;
40635
40574
  }
@@ -40648,8 +40587,8 @@ function readFenceValue(text) {
40648
40587
  return values.size === 1 ? [...values][0] ?? null : null;
40649
40588
  }
40650
40589
  function readFenceFromDist(packageDirectory) {
40651
- const distDirectory = join22(packageDirectory, "dist");
40652
- if (!existsSync30(distDirectory))
40590
+ const distDirectory = join21(packageDirectory, "dist");
40591
+ if (!existsSync29(distDirectory))
40653
40592
  return null;
40654
40593
  const pending = [distDirectory];
40655
40594
  const fenceValues = new Set;
@@ -40659,14 +40598,14 @@ function readFenceFromDist(packageDirectory) {
40659
40598
  continue;
40660
40599
  try {
40661
40600
  for (const entry of readdirSync6(directory, { withFileTypes: true })) {
40662
- const path = join22(directory, entry.name);
40601
+ const path = join21(directory, entry.name);
40663
40602
  if (entry.isDirectory()) {
40664
40603
  pending.push(path);
40665
40604
  continue;
40666
40605
  }
40667
40606
  if (!entry.isFile() || !/\.(?:[cm]?js|ts)$/.test(entry.name))
40668
40607
  continue;
40669
- const fence = readFenceValue(readFileSync20(path, "utf-8"));
40608
+ const fence = readFenceValue(readFileSync19(path, "utf-8"));
40670
40609
  if (fence !== null)
40671
40610
  fenceValues.add(fence);
40672
40611
  }
@@ -40677,20 +40616,20 @@ function readFenceFromDist(packageDirectory) {
40677
40616
  return fenceValues.size === 1 ? [...fenceValues][0] ?? null : null;
40678
40617
  }
40679
40618
  function findInstalledPluginPackage(cacheDirectory, specifier, requestedVersion) {
40680
- const directCacheRoot = join22(cacheDirectory, specifier);
40619
+ const directCacheRoot = join21(cacheDirectory, specifier);
40681
40620
  const candidates = [directCacheRoot];
40682
40621
  try {
40683
40622
  for (const entry of readdirSync6(cacheDirectory, { withFileTypes: true })) {
40684
40623
  if (!entry.isDirectory())
40685
40624
  continue;
40686
- const candidate = join22(cacheDirectory, entry.name);
40625
+ const candidate = join21(cacheDirectory, entry.name);
40687
40626
  if (!candidates.includes(candidate))
40688
40627
  candidates.push(candidate);
40689
40628
  }
40690
40629
  } catch {}
40691
40630
  for (const cacheRoot of candidates) {
40692
- const directory = join22(cacheRoot, "node_modules", ...PACKAGE_PATH_SEGMENTS);
40693
- const version = readPackageVersion(join22(directory, "package.json"));
40631
+ const directory = join21(cacheRoot, "node_modules", ...PACKAGE_PATH_SEGMENTS);
40632
+ const version = readPackageVersion(join21(directory, "package.json"));
40694
40633
  if (!version)
40695
40634
  continue;
40696
40635
  if (cacheRoot === directCacheRoot || EXACT_VERSION_PATTERN.test(requestedVersion) && version === requestedVersion) {
@@ -40835,13 +40774,13 @@ var init_opencode_plugin_schema_fence = __esm(async () => {
40835
40774
  });
40836
40775
 
40837
40776
  // src/commands/doctor-opencode-cache.ts
40838
- import { existsSync as existsSync31, readFileSync as readFileSync21, rmSync as rmSync7 } from "node:fs";
40777
+ import { existsSync as existsSync30, readFileSync as readFileSync20, rmSync as rmSync7 } from "node:fs";
40839
40778
  function readCachedPluginVersion(pluginCacheDir) {
40840
40779
  try {
40841
40780
  const installedPkgPath = getOpenCodePluginPackageJsonPath(pluginCacheDir);
40842
- if (!existsSync31(installedPkgPath))
40781
+ if (!existsSync30(installedPkgPath))
40843
40782
  return;
40844
- const pkg = JSON.parse(readFileSync21(installedPkgPath, "utf-8"));
40783
+ const pkg = JSON.parse(readFileSync20(installedPkgPath, "utf-8"));
40845
40784
  return typeof pkg.version === "string" ? pkg.version : undefined;
40846
40785
  } catch {
40847
40786
  return;
@@ -40868,7 +40807,7 @@ function readOpenCodePluginConfigUse(config, configDir) {
40868
40807
  async function clearPluginCache(options = {}, deps = {}) {
40869
40808
  const remove = deps.remove ?? ((path) => rmSync7(path, { recursive: true, force: true }));
40870
40809
  const pluginCacheRoots = getOpenCodePluginCacheRoots();
40871
- const existingRoots = pluginCacheRoots.filter((root) => existsSync31(root));
40810
+ const existingRoots = pluginCacheRoots.filter((root) => existsSync30(root));
40872
40811
  if (existingRoots.length === 0) {
40873
40812
  return { action: "not_found", path: pluginCacheRoots[0] ?? "" };
40874
40813
  }
@@ -40965,7 +40904,7 @@ var init_doctor_opencode_cache = __esm(async () => {
40965
40904
  });
40966
40905
 
40967
40906
  // src/commands/doctor-cached-plugin-fence.ts
40968
- import { existsSync as existsSync32 } from "node:fs";
40907
+ import { existsSync as existsSync31 } from "node:fs";
40969
40908
  import { dirname as dirname18 } from "node:path";
40970
40909
  function isReferenced(sources, host, spec) {
40971
40910
  const specs = sources.referencedSpecs?.[host];
@@ -40976,7 +40915,7 @@ function listCachedOpenCodePluginFences(sources = {}) {
40976
40915
  const v1Referenced = isReferenced(sources, "opencode1", "latest");
40977
40916
  for (const root of v1Referenced ? sources.openCodeV1Roots ?? getOpenCodePluginCacheRoots() : []) {
40978
40917
  const packageJson = getOpenCodePluginPackageJsonPath(root);
40979
- if (!existsSync32(packageJson))
40918
+ if (!existsSync31(packageJson))
40980
40919
  continue;
40981
40920
  fences.push({
40982
40921
  host: "opencode1",
@@ -41181,8 +41120,8 @@ var init_doctor_prune_discovery = __esm(async () => {
41181
41120
 
41182
41121
  // src/commands/doctor-storage-holders.ts
41183
41122
  import { execFileSync as execFileSync5 } from "node:child_process";
41184
- import { readFileSync as readFileSync22, realpathSync as realpathSync6 } from "node:fs";
41185
- import { join as join23, resolve as resolve11 } from "node:path";
41123
+ import { readFileSync as readFileSync21, realpathSync as realpathSync6 } from "node:fs";
41124
+ import { join as join22, resolve as resolve11 } from "node:path";
41186
41125
  function canonicalStoragePath(path) {
41187
41126
  try {
41188
41127
  return realpathSync6(path);
@@ -41199,7 +41138,7 @@ function textReferencesStorage(text, storageDir) {
41199
41138
  continue;
41200
41139
  if (canonicalStoragePath(value) === target)
41201
41140
  return true;
41202
- if (token.startsWith("XDG_DATA_HOME=") && canonicalStoragePath(join23(value, "cortexkit", "magic-context")) === target)
41141
+ if (token.startsWith("XDG_DATA_HOME=") && canonicalStoragePath(join22(value, "cortexkit", "magic-context")) === target)
41203
41142
  return true;
41204
41143
  }
41205
41144
  return false;
@@ -41209,7 +41148,7 @@ function processReferencesStorage(pid, storageDir) {
41209
41148
  if (process.platform === "linux") {
41210
41149
  for (const name of ["cmdline", "environ"]) {
41211
41150
  try {
41212
- texts.push(readFileSync22(`/proc/${pid}/${name}`, "utf8"));
41151
+ texts.push(readFileSync21(`/proc/${pid}/${name}`, "utf8"));
41213
41152
  } catch {}
41214
41153
  }
41215
41154
  } else {
@@ -41231,12 +41170,12 @@ var init_doctor_storage_holders = () => {};
41231
41170
 
41232
41171
  // src/commands/doctor-repair-db.ts
41233
41172
  import { spawnSync as spawnSync4 } from "node:child_process";
41234
- import { closeSync as closeSync4, existsSync as existsSync33, openSync as openSync4, renameSync as renameSync6, rmSync as rmSync8, statSync as statSync16 } from "node:fs";
41173
+ import { closeSync as closeSync4, existsSync as existsSync32, openSync as openSync4, renameSync as renameSync6, rmSync as rmSync8, statSync as statSync16 } from "node:fs";
41235
41174
  import { homedir as homedir17 } from "node:os";
41236
- import { dirname as dirname19, join as join24 } from "node:path";
41175
+ import { dirname as dirname19, join as join23 } from "node:path";
41237
41176
  function defaultInspectHolders(storageDir, overrides = {}) {
41238
41177
  const deps = {
41239
- defaultStorageDir: join24(homedir17(), ".local", "share", "cortexkit", "magic-context"),
41178
+ defaultStorageDir: join23(homedir17(), ".local", "share", "cortexkit", "magic-context"),
41240
41179
  inspectRpc: inspectRpcServerDiscovery,
41241
41180
  inspectPi: inspectLivePiProcesses,
41242
41181
  probeFiles: probeHostProcessesUsing,
@@ -41253,7 +41192,7 @@ function defaultInspectHolders(storageDir, overrides = {}) {
41253
41192
  return {
41254
41193
  safe: false,
41255
41194
  blockers: [],
41256
- uncertainty: `RPC discovery ${rpc.unreadableFile ?? join24(storageDir, "rpc")} ${arm}`
41195
+ uncertainty: `RPC discovery ${rpc.unreadableFile ?? join23(storageDir, "rpc")} ${arm}`
41257
41196
  };
41258
41197
  }
41259
41198
  const blockers = rpc.state === "live" ? rpc.serverPids.map((pid) => `OpenCode server (PID ${pid})`) : [];
@@ -41266,7 +41205,7 @@ function defaultInspectHolders(storageDir, overrides = {}) {
41266
41205
  const pi = overrides.inspectPi ? deps.inspectPi() : processes?.pi ?? deps.inspectPi();
41267
41206
  if (canonicalStoragePath(storageDir) !== canonicalStoragePath(deps.defaultStorageDir)) {
41268
41207
  const holders = deps.probeFiles({
41269
- files: ["context.db", "store.db"].flatMap((name) => DATABASE_SUFFIXES.map((suffix) => join24(storageDir, `${name}${suffix}`))),
41208
+ files: ["context.db", "store.db"].flatMap((name) => DATABASE_SUFFIXES.map((suffix) => join23(storageDir, `${name}${suffix}`))),
41270
41209
  directories: []
41271
41210
  });
41272
41211
  if (holders.status === "unknown") {
@@ -41299,11 +41238,11 @@ function timestamp(date) {
41299
41238
  return date.toISOString().replaceAll("-", "").replaceAll(":", "").replace(".", "");
41300
41239
  }
41301
41240
  function uniqueBase(preferred) {
41302
- if (!DATABASE_SUFFIXES.some((suffix) => existsSync33(`${preferred}${suffix}`)))
41241
+ if (!DATABASE_SUFFIXES.some((suffix) => existsSync32(`${preferred}${suffix}`)))
41303
41242
  return preferred;
41304
41243
  for (let attempt = 1;attempt < 1e4; attempt++) {
41305
41244
  const candidate = `${preferred}-${attempt}`;
41306
- if (!DATABASE_SUFFIXES.some((suffix) => existsSync33(`${candidate}${suffix}`)))
41245
+ if (!DATABASE_SUFFIXES.some((suffix) => existsSync32(`${candidate}${suffix}`)))
41307
41246
  return candidate;
41308
41247
  }
41309
41248
  throw new Error(`Could not allocate a unique recovery path beside ${preferred}`);
@@ -41317,7 +41256,7 @@ function databaseBundleSizeBytes(sourceBase) {
41317
41256
  let size = 0;
41318
41257
  for (const suffix of DATABASE_SUFFIXES) {
41319
41258
  const source = `${sourceBase}${suffix}`;
41320
- if (existsSync33(source))
41259
+ if (existsSync32(source))
41321
41260
  size += statSync16(source).size;
41322
41261
  }
41323
41262
  return size;
@@ -41326,7 +41265,7 @@ function copyDatabaseBundle(sourceBase, destinationBase, forcePrivate = false) {
41326
41265
  const copiedPaths = [];
41327
41266
  for (const suffix of DATABASE_SUFFIXES) {
41328
41267
  const source = `${sourceBase}${suffix}`;
41329
- if (!existsSync33(source))
41268
+ if (!existsSync32(source))
41330
41269
  continue;
41331
41270
  const destination = `${destinationBase}${suffix}`;
41332
41271
  copyStorageFileSync(source, destination, forcePrivate);
@@ -41548,7 +41487,7 @@ function activateReplacement(dbPath, replacementPath, originalAsidePath) {
41548
41487
  try {
41549
41488
  for (const suffix of DATABASE_SUFFIXES) {
41550
41489
  const from = `${dbPath}${suffix}`;
41551
- if (!existsSync33(from))
41490
+ if (!existsSync32(from))
41552
41491
  continue;
41553
41492
  const to = `${originalAsidePath}${suffix}`;
41554
41493
  renameSync6(from, to);
@@ -41558,7 +41497,7 @@ function activateReplacement(dbPath, replacementPath, originalAsidePath) {
41558
41497
  return movedOriginals.map(({ to }) => to);
41559
41498
  } catch (error) {
41560
41499
  for (const moved of movedOriginals.reverse()) {
41561
- if (existsSync33(moved.to) && !existsSync33(moved.from))
41500
+ if (existsSync32(moved.to) && !existsSync32(moved.from))
41562
41501
  renameSync6(moved.to, moved.from);
41563
41502
  }
41564
41503
  throw error;
@@ -41589,12 +41528,12 @@ function printHelp() {
41589
41528
  async function runRepairDb(options = {}) {
41590
41529
  const prompts = options.prompts ?? promptIO;
41591
41530
  const deps = { ...DEFAULT_DEPS3, ...options.deps };
41592
- const storageDir = options.storageDir ?? dirname19(options.dbPath ?? join24(getMagicContextStorageDir(), "context.db"));
41593
- const dbPath = options.dbPath ?? join24(storageDir, "context.db");
41531
+ const storageDir = options.storageDir ?? dirname19(options.dbPath ?? join23(getMagicContextStorageDir(), "context.db"));
41532
+ const dbPath = options.dbPath ?? join23(storageDir, "context.db");
41594
41533
  const stamp = timestamp(deps.now());
41595
41534
  prompts.intro("Magic Context — Repair shared database");
41596
41535
  prompts.log.info(`Database: ${dbPath}`);
41597
- if (!existsSync33(dbPath)) {
41536
+ if (!existsSync32(dbPath)) {
41598
41537
  prompts.log.error(`Database not found: ${dbPath}`);
41599
41538
  prompts.log.info("Backup: not created (database does not exist)");
41600
41539
  prompts.outro("Database repair failed");
@@ -41804,12 +41743,12 @@ var init_doctor_repair_db = __esm(async () => {
41804
41743
 
41805
41744
  // src/commands/doctor-single-store-repair.ts
41806
41745
  import { spawnSync as spawnSync5 } from "node:child_process";
41807
- import { existsSync as existsSync34, statfsSync as statfsSync2, statSync as statSync17 } from "node:fs";
41746
+ import { existsSync as existsSync33, statfsSync as statfsSync2, statSync as statSync17 } from "node:fs";
41808
41747
  import { homedir as homedir18 } from "node:os";
41809
- import { dirname as dirname20, join as join25, resolve as resolve12 } from "node:path";
41748
+ import { dirname as dirname20, join as join24, resolve as resolve12 } from "node:path";
41810
41749
  function existingAncestor(path) {
41811
41750
  let current = resolve12(path);
41812
- while (!existsSync34(current))
41751
+ while (!existsSync33(current))
41813
41752
  current = dirname20(current);
41814
41753
  return current;
41815
41754
  }
@@ -41845,15 +41784,15 @@ function runDoctorSingleStoreRepair(options, overrides = {}) {
41845
41784
  };
41846
41785
  try {
41847
41786
  const { dbPath: context, dbDir: data } = resolveDatabasePath();
41848
- const store = join25(data, "store.db");
41849
- if (!existsSync34(context) || !existsSync34(store))
41787
+ const store = join24(data, "store.db");
41788
+ if (!existsSync33(context) || !existsSync33(store))
41850
41789
  return refuse("repair_missing_database", `Both ${context} and ${store} must exist.`);
41851
41790
  if (!options.fromBackup)
41852
41791
  return refuse("repair_usage", "--from-backup <dir> is required");
41853
41792
  const fromBackup = resolve12(options.fromBackup);
41854
41793
  for (const name of ["context.db", "store.db"])
41855
- if (!existsSync34(join25(fromBackup, name)))
41856
- return refuse("repair_backup_missing", `${join25(fromBackup, name)} does not exist`);
41794
+ if (!existsSync33(join24(fromBackup, name)))
41795
+ return refuse("repair_backup_missing", `${join24(fromBackup, name)} does not exist`);
41857
41796
  const sessions = options.sessions ?? [];
41858
41797
  if (options.live && sessions.length === 0)
41859
41798
  return refuse("repair_usage", "--live repairs named sessions only; pass --session <id>");
@@ -41880,16 +41819,16 @@ function runDoctorSingleStoreRepair(options, overrides = {}) {
41880
41819
  `));
41881
41820
  deps.print(`Repairing while hosts hold the stores (--live): ${blockers.join("; ") || "holders unknown"}`);
41882
41821
  }
41883
- const backupRoot = resolve12(options.backupRoot ?? join25(data, "backups"));
41822
+ const backupRoot = resolve12(options.backupRoot ?? join24(data, "backups"));
41884
41823
  const need = Math.ceil((statSync17(context).size + statSync17(store).size) * 1.1);
41885
41824
  const volume = existingAncestor(backupRoot);
41886
41825
  const have = deps.freeBytes(volume);
41887
41826
  if (have < need)
41888
41827
  return refuse("repair_disk_space", `the backup needs ${need} bytes; have ${have} bytes on ${volume}`);
41889
- backupDir = join25(backupRoot, `repair-history-${deps.now().toISOString().replaceAll(":", "-")}`);
41828
+ backupDir = join24(backupRoot, `repair-history-${deps.now().toISOString().replaceAll(":", "-")}`);
41890
41829
  deps.print(`Backing up the live stores to ${backupDir} before any write.`);
41891
41830
  }
41892
- const binary = options.ckMc ?? join25(homedir18(), ".local", "share", "cortexkit", "bin", "ck-mc");
41831
+ const binary = options.ckMc ?? join24(homedir18(), ".local", "share", "cortexkit", "bin", "ck-mc");
41893
41832
  const args = [
41894
41833
  "single-store-repair-history",
41895
41834
  "--context-db",
@@ -41977,22 +41916,22 @@ var init_doctor_single_store_repair = __esm(async () => {
41977
41916
 
41978
41917
  // src/commands/doctor-single-store.ts
41979
41918
  import { spawnSync as spawnSync6 } from "node:child_process";
41980
- import { existsSync as existsSync35, realpathSync as realpathSync7, statSync as statSync18 } from "node:fs";
41919
+ import { existsSync as existsSync34, realpathSync as realpathSync7, statSync as statSync18 } from "node:fs";
41981
41920
  import { homedir as homedir19 } from "node:os";
41982
- import { join as join26, resolve as resolve13 } from "node:path";
41921
+ import { join as join25, resolve as resolve13 } from "node:path";
41983
41922
  function engineContextPath() {
41984
41923
  const value = (key) => process.env[key]?.trim() || undefined;
41985
41924
  const test = value("MAGIC_CONTEXT_TEST_DATA_DIR");
41986
41925
  const xdg = value("XDG_DATA_HOME");
41987
- const dir = test ? join26(xdg && xdg !== test ? xdg : test, "cortexkit", "magic-context") : value("MAGIC_CONTEXT_STORAGE_DIR") ?? join26(xdg ?? join26(value("HOME") ?? ".", ".local", "share"), "cortexkit", "magic-context");
41988
- return join26(dir, "context.db");
41926
+ const dir = test ? join25(xdg && xdg !== test ? xdg : test, "cortexkit", "magic-context") : value("MAGIC_CONTEXT_STORAGE_DIR") ?? join25(xdg ?? join25(value("HOME") ?? ".", ".local", "share"), "cortexkit", "magic-context");
41927
+ return join25(dir, "context.db");
41989
41928
  }
41990
41929
  function undo(backup, data, print) {
41991
41930
  const quote = (s) => `'${s.replaceAll("'", "'\\''")}'`;
41992
41931
  print(`Backup: ${backup}`);
41993
41932
  print("To undo: quit every host, then");
41994
- print(` rm -f ${["context.db-wal", "context.db-shm", "store.db-wal", "store.db-shm"].map((name) => quote(join26(data, name))).join(" ")}`);
41995
- print(` cp ${quote(join26(backup, "context.db"))} ${quote(join26(backup, "store.db"))} ${quote(data + "/")}`);
41933
+ print(` rm -f ${["context.db-wal", "context.db-shm", "store.db-wal", "store.db-shm"].map((name) => quote(join25(data, name))).join(" ")}`);
41934
+ print(` cp ${quote(join25(backup, "context.db"))} ${quote(join25(backup, "store.db"))} ${quote(data + "/")}`);
41996
41935
  print("This restores the unmigrated stores. Keep the current plugin and ck-mc: TypeScript mode works as before, and Rust mode will refuse with MC-C14 until you run this command again.");
41997
41936
  }
41998
41937
  function runDoctorSingleStore(options = {}, overrides = {}) {
@@ -42010,8 +41949,8 @@ function runDoctorSingleStore(options = {}, overrides = {}) {
42010
41949
  };
42011
41950
  try {
42012
41951
  const { dbPath: context, dbDir: data } = resolveDatabasePath();
42013
- const store = join26(data, "store.db");
42014
- if (!existsSync35(context) || !existsSync35(store))
41952
+ const store = join25(data, "store.db");
41953
+ if (!existsSync34(context) || !existsSync34(store))
42015
41954
  return refuse("single_store_missing_database", `Both ${context} and ${store} must exist.`);
42016
41955
  const probe = probeHostProcessesUsing({ files: [context, store].flatMap((p) => SUFFIXES2.map((s) => p + s)), directories: [] }, deps.lsofSpawn);
42017
41956
  const holders = deps.inspectHolders(data);
@@ -42026,9 +41965,9 @@ function runDoctorSingleStore(options = {}, overrides = {}) {
42026
41965
  return refuse("single_store_files_in_use", [...lines, STOP].join(`
42027
41966
  `));
42028
41967
  }
42029
- if (!existsSync35(engineContextPath()) || realpathSync7(context) !== realpathSync7(engineContextPath()))
41968
+ if (!existsSync34(engineContextPath()) || realpathSync7(context) !== realpathSync7(engineContextPath()))
42030
41969
  return refuse("single_store_path_mismatch", `CLI ${context}; engine ${engineContextPath()}`);
42031
- const backupRoot = resolve13(options.backupRoot ?? join26(data, "backups"));
41970
+ const backupRoot = resolve13(options.backupRoot ?? join25(data, "backups"));
42032
41971
  const contextDb = openExistingDatabase(context, { readonly: true });
42033
41972
  if (!contextDb)
42034
41973
  return refuse("single_store_missing_database", `Database disappeared: ${context}`);
@@ -42070,7 +42009,7 @@ function runDoctorSingleStore(options = {}, overrides = {}) {
42070
42009
  const backupSpace = sameVolume ? undefined : checkDiskSpace(backupVolume, backupBytes, deps.freeBytes);
42071
42010
  if (backupSpace && !backupSpace.sufficient)
42072
42011
  return refuse("single_store_disk_space", `backup needs ${backupSpace.requiredBytes} bytes; have ${backupSpace.availableBytes} bytes on ${backupVolume}`);
42073
- const backupDir = join26(backupRoot, `single-store-${deps.now().toISOString().replaceAll(":", "-")}`);
42012
+ const backupDir = join25(backupRoot, `single-store-${deps.now().toISOString().replaceAll(":", "-")}`);
42074
42013
  undo(backupDir, data, deps.print);
42075
42014
  const opened = openDatabase(context);
42076
42015
  if (!opened)
@@ -42082,7 +42021,7 @@ function runDoctorSingleStore(options = {}, overrides = {}) {
42082
42021
  }
42083
42022
  if (contextVersion !== LATEST_SUPPORTED_VERSION)
42084
42023
  return refuse("single_store_version_mismatch", `context.db v${contextVersion}; store.db v${storeVersion}`);
42085
- const binary = options.ckMc ?? join26(homedir19(), ".local", "share", "cortexkit", "bin", "ck-mc");
42024
+ const binary = options.ckMc ?? join25(homedir19(), ".local", "share", "cortexkit", "bin", "ck-mc");
42086
42025
  const args = [
42087
42026
  "single-store-migrate",
42088
42027
  "--context-db",
@@ -42574,15 +42513,15 @@ var init_storage_identity_merge = __esm(() => {
42574
42513
  // src/commands/doctor-identity-splits.ts
42575
42514
  import { execFileSync as execFileSync6 } from "node:child_process";
42576
42515
  import { createHash as createHash6 } from "node:crypto";
42577
- import { existsSync as existsSync36, readdirSync as readdirSync7, realpathSync as realpathSync8, statSync as statSync19 } from "node:fs";
42578
- import { dirname as dirname21, join as join27, resolve as resolve14 } from "node:path";
42516
+ import { existsSync as existsSync35, readdirSync as readdirSync7, realpathSync as realpathSync8, statSync as statSync19 } from "node:fs";
42517
+ import { dirname as dirname21, join as join26, resolve as resolve14 } from "node:path";
42579
42518
  function tableExists5(db, table) {
42580
42519
  return !!db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table);
42581
42520
  }
42582
42521
  function hasGitMetadataInAncestors(directory) {
42583
42522
  let current = resolve14(directory);
42584
42523
  while (true) {
42585
- if (existsSync36(join27(current, ".git")))
42524
+ if (existsSync35(join26(current, ".git")))
42586
42525
  return true;
42587
42526
  const parent = dirname21(current);
42588
42527
  if (parent === current)
@@ -42737,7 +42676,7 @@ function identityLines(split) {
42737
42676
  return split.identities.map((row) => ` ${row.identity}: ${row.sessions} sessions, ${row.memories} memories, ${row.notes} notes, ${row.dreamer} dreamer rows (identity-wide counts)`);
42738
42677
  }
42739
42678
  function diagnoseIdentitySplits() {
42740
- const db = openExistingContextDatabase(join27(getMagicContextStorageDir(), "context.db"), {
42679
+ const db = openExistingContextDatabase(join26(getMagicContextStorageDir(), "context.db"), {
42741
42680
  readonly: true
42742
42681
  });
42743
42682
  if (!db)
@@ -42763,8 +42702,8 @@ var init_doctor_identity_splits = __esm(async () => {
42763
42702
  // src/commands/doctor-merge-identity.ts
42764
42703
  import { execFileSync as execFileSync7 } from "node:child_process";
42765
42704
  import { createHash as createHash7 } from "node:crypto";
42766
- import { existsSync as existsSync37, mkdtempSync as mkdtempSync2, readdirSync as readdirSync8, readFileSync as readFileSync23, statSync as statSync20 } from "node:fs";
42767
- import { dirname as dirname22, join as join28, resolve as resolve15 } from "node:path";
42705
+ import { existsSync as existsSync36, mkdtempSync as mkdtempSync2, readdirSync as readdirSync8, readFileSync as readFileSync22, statSync as statSync20 } from "node:fs";
42706
+ import { dirname as dirname22, join as join27, resolve as resolve15 } from "node:path";
42768
42707
  function parseMergeIdentityArgs(args) {
42769
42708
  const values = {};
42770
42709
  const switches = new Set(["--apply", "--force", "--dry-run", "--yes", "--verbose"]);
@@ -42814,7 +42753,7 @@ function printReport(report) {
42814
42753
  console.log(" No writes. Review this preview, then repeat with --apply to confirm.");
42815
42754
  }
42816
42755
  function resolveReadOnly(directory) {
42817
- if (!existsSync37(directory))
42756
+ if (!existsSync36(directory))
42818
42757
  return;
42819
42758
  try {
42820
42759
  const roots = execFileSync7("git", ["rev-list", "--max-parents=0", "HEAD"], {
@@ -42970,13 +42909,13 @@ function observations(db, hostPath, storageDir) {
42970
42909
  if (!row.identities.some((item) => item.identity === identity))
42971
42910
  row.identities.push({ identity, sessions: 0, memories: 0, notes: 0, dreamer: 0 });
42972
42911
  };
42973
- const sidecars = join28(storageDir, "project-identities");
42974
- if (existsSync37(sidecars))
42912
+ const sidecars = join27(storageDir, "project-identities");
42913
+ if (existsSync36(sidecars))
42975
42914
  for (const file of readdirSync8(sidecars)) {
42976
42915
  if (!file.endsWith(".json"))
42977
42916
  continue;
42978
42917
  try {
42979
- const record = JSON.parse(readFileSync23(join28(sidecars, file), "utf8"));
42918
+ const record = JSON.parse(readFileSync22(join27(sidecars, file), "utf8"));
42980
42919
  if (typeof record.directory === "string" && typeof record.identity === "string")
42981
42920
  add(record.directory, record.identity);
42982
42921
  } catch {}
@@ -42987,9 +42926,9 @@ function observations(db, hostPath, storageDir) {
42987
42926
  }
42988
42927
  function runMergeIdentityCli(args, deps = {}) {
42989
42928
  const options = parseMergeIdentityArgs(args);
42990
- const dbPath = options.dbPath ?? join28(getMagicContextStorageDir(), "context.db");
42929
+ const dbPath = options.dbPath ?? join27(getMagicContextStorageDir(), "context.db");
42991
42930
  const storageDir = dirname22(dbPath);
42992
- const hostPath = options.hostPath ?? (options.dbPath ? join28(storageDir, "host.db") : resolveOpenCodeDbPath().path);
42931
+ const hostPath = options.hostPath ?? (options.dbPath ? join27(storageDir, "host.db") : resolveOpenCodeDbPath().path);
42993
42932
  let db = openExistingContextDatabase(dbPath, {
42994
42933
  readonly: true,
42995
42934
  minimumSupportedVersion: CLI_SCHEMA_FLOOR_VERSION
@@ -43042,27 +42981,27 @@ function runMergeIdentityCli(args, deps = {}) {
43042
42981
  throw new Error(`Refusing merge: close OpenCode, Pi, OpenCode 2 and ck-mc. ${holders.blockers.join(", ")} ${holders.uncertainty ?? ""} ${probe.status === "in_use" ? `context.db holders: ${probe.pids.join(", ")}` : probe.status === "unknown" ? probe.reason : ""}`);
43043
42982
  const backupRoot = resolve15(options.backupRoot ?? storageDir);
43044
42983
  const backupVolume = existingDirectoryAncestor(backupRoot);
43045
- const sidecarRoot = join28(storageDir, "project-identities");
43046
- const sidecarEntries = existsSync37(sidecarRoot) ? readdirSync8(sidecarRoot).filter((entry) => entry.endsWith(".json")) : [];
43047
- const sidecarBytes = sidecarEntries.reduce((size, entry) => size + statSync20(join28(sidecarRoot, entry)).size, 0);
42984
+ const sidecarRoot = join27(storageDir, "project-identities");
42985
+ const sidecarEntries = existsSync36(sidecarRoot) ? readdirSync8(sidecarRoot).filter((entry) => entry.endsWith(".json")) : [];
42986
+ const sidecarBytes = sidecarEntries.reduce((size, entry) => size + statSync20(join27(sidecarRoot, entry)).size, 0);
43048
42987
  const diskSpace = checkDiskSpace(backupVolume, databaseBundleSizeBytes(dbPath) + sidecarBytes, deps.freeBytes ?? availableDiskBytes);
43049
42988
  if (!diskSpace.sufficient)
43050
42989
  throw new Error(`merge_identity_disk_space: refusing identity merge: backup needs ${diskSpace.requiredBytes} bytes; have ${diskSpace.availableBytes} bytes on ${backupVolume}. Use --backup-root <dir> to choose a volume with enough free space.`);
43051
42990
  ensureStorageDirectorySync(backupRoot, true);
43052
- const backup = mkdtempSync2(join28(backupRoot, "identity-merge-backup-"));
42991
+ const backup = mkdtempSync2(join27(backupRoot, "identity-merge-backup-"));
43053
42992
  const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
43054
42993
  console.log(`Backup directory: ${backup}`);
43055
- console.log(`Restore with hosts closed: rm -f ${quote(`${dbPath}-wal`)} ${quote(`${dbPath}-shm`)}; cp ${quote(join28(backup, "context.db"))} ${quote(dbPath)}; if test -f ${quote(join28(backup, "context.db-wal"))}; then cp ${quote(join28(backup, "context.db-wal"))} ${quote(`${dbPath}-wal`)}; fi`);
43056
- const sidecarBackup = join28(backup, "project-identities");
42994
+ console.log(`Restore with hosts closed: rm -f ${quote(`${dbPath}-wal`)} ${quote(`${dbPath}-shm`)}; cp ${quote(join27(backup, "context.db"))} ${quote(dbPath)}; if test -f ${quote(join27(backup, "context.db-wal"))}; then cp ${quote(join27(backup, "context.db-wal"))} ${quote(`${dbPath}-wal`)}; fi`);
42995
+ const sidecarBackup = join27(backup, "project-identities");
43057
42996
  ensureStorageDirectorySync(sidecarBackup, true);
43058
42997
  let backupBytes = 0;
43059
42998
  for (const entry of sidecarEntries) {
43060
- const content = readFileSync23(join28(sidecarRoot, entry));
43061
- writeStorageFileAtomicSync(join28(sidecarBackup, entry), content, true);
42999
+ const content = readFileSync22(join27(sidecarRoot, entry));
43000
+ writeStorageFileAtomicSync(join27(sidecarBackup, entry), content, true);
43062
43001
  backupBytes += content.byteLength;
43063
43002
  }
43064
43003
  console.log(`Restore identity sidecars too: rm -rf ${quote(sidecarRoot)}; cp -R ${quote(sidecarBackup)} ${quote(sidecarRoot)}`);
43065
- const copiedDatabaseFiles = copyDatabaseBundle(dbPath, join28(backup, "context.db"), true);
43004
+ const copiedDatabaseFiles = copyDatabaseBundle(dbPath, join27(backup, "context.db"), true);
43066
43005
  backupBytes += copiedDatabaseFiles.reduce((size, path) => size + statSync20(path).size, 0);
43067
43006
  db = openExistingDatabase(dbPath, { readonly: false });
43068
43007
  if (!db)
@@ -43081,9 +43020,9 @@ function runMergeIdentityCli(args, deps = {}) {
43081
43020
  }
43082
43021
  if (to.startsWith("git:"))
43083
43022
  for (const directory of directories) {
43084
- const root = join28(storageDir, "project-identities");
43023
+ const root = join27(storageDir, "project-identities");
43085
43024
  ensureStorageDirectorySync(root);
43086
- const path = join28(root, `${createHash7("sha256").update(projectDirectoryKey(directory)).digest("hex")}.json`);
43025
+ const path = join27(root, `${createHash7("sha256").update(projectDirectoryKey(directory)).digest("hex")}.json`);
43087
43026
  writeStorageFileAtomicSync(path, JSON.stringify({ directory: projectDirectoryKey(directory), identity: options.to }));
43088
43027
  }
43089
43028
  console.log(`Backup: ${backup} (${backupBytes} bytes)`);
@@ -43107,8 +43046,8 @@ var init_doctor_merge_identity = __esm(async () => {
43107
43046
  });
43108
43047
 
43109
43048
  // src/commands/doctor-git-fts-map.ts
43110
- import { existsSync as existsSync38, mkdtempSync as mkdtempSync3, statSync as statSync21 } from "node:fs";
43111
- import { join as join29, resolve as resolve16 } from "node:path";
43049
+ import { existsSync as existsSync37, mkdtempSync as mkdtempSync3, statSync as statSync21 } from "node:fs";
43050
+ import { join as join28, resolve as resolve16 } from "node:path";
43112
43051
  function inspectGitFtsMap(db) {
43113
43052
  const has = (name) => Boolean(db.prepare("SELECT 1 FROM sqlite_master WHERE name=? AND type='table'").get(name));
43114
43053
  const indexed = has("git_commits_fts");
@@ -43161,8 +43100,8 @@ function runDoctorGitFtsMap(options = {}, overrides = {}) {
43161
43100
  verify: verifyInventory,
43162
43101
  ...overrides
43163
43102
  };
43164
- const context = join29(deps.storageDir, "context.db");
43165
- const store = join29(deps.storageDir, "store.db");
43103
+ const context = join28(deps.storageDir, "context.db");
43104
+ const store = join28(deps.storageDir, "store.db");
43166
43105
  let db = null, storeDb = null;
43167
43106
  let contextLocked = false, storeLocked = false;
43168
43107
  try {
@@ -43184,7 +43123,7 @@ function runDoctorGitFtsMap(options = {}, overrides = {}) {
43184
43123
  deps.print(`Stop every host, then run \`${GIT_FTS_MAP_REPAIR_COMMAND}\`. The repair backs up context.db and store.db first.`);
43185
43124
  return damaged ? 1 : 0;
43186
43125
  }
43187
- if (!existsSync38(context) || !existsSync38(store))
43126
+ if (!existsSync37(context) || !existsSync37(store))
43188
43127
  throw new Error("Both context.db and store.db must exist before paired-backup repair; no replacement store will be created");
43189
43128
  const cstat = statSync21(context), sstat = statSync21(store);
43190
43129
  if (cstat.dev === sstat.dev && cstat.ino === sstat.ino)
@@ -43214,12 +43153,12 @@ function runDoctorGitFtsMap(options = {}, overrides = {}) {
43214
43153
  const stillFree = deps.inspectHolders(deps.storageDir);
43215
43154
  if (!stillFree.safe)
43216
43155
  throw new Error(`A host appeared before backup: ${[...stillFree.blockers, stillFree.uncertainty].filter(Boolean).join("; ")}`);
43217
- const backupRoot = resolve16(options.backupRoot ?? join29(deps.storageDir, "backups"));
43156
+ const backupRoot = resolve16(options.backupRoot ?? join28(deps.storageDir, "backups"));
43218
43157
  ensureStorageDirectorySync(backupRoot, true);
43219
- const backup = mkdtempSync3(join29(backupRoot, "git-fts-map-"));
43220
- snapshot(context, join29(backup, "context.db"));
43221
- snapshot(store, join29(backup, "store.db"));
43222
- writeStorageFileSync(join29(backup, "manifest.json"), JSON.stringify({
43158
+ const backup = mkdtempSync3(join28(backupRoot, "git-fts-map-"));
43159
+ snapshot(context, join28(backup, "context.db"));
43160
+ snapshot(store, join28(backup, "store.db"));
43161
+ writeStorageFileSync(join28(backup, "manifest.json"), JSON.stringify({
43223
43162
  contextVersion: version,
43224
43163
  createdAt: new Date().toISOString(),
43225
43164
  repair: "git-fts-map",
@@ -43387,19 +43326,19 @@ var SINGLE_STORE_REQUIRED = "Magic Context's Rust mode needs a one-time migratio
43387
43326
 
43388
43327
  // src/commands/migrate.ts
43389
43328
  import { createHash as createHash8, randomBytes as randomBytes3 } from "node:crypto";
43390
- import { existsSync as existsSync39, mkdirSync as mkdirSync7, renameSync as renameSync7, unlinkSync as unlinkSync4 } from "node:fs";
43391
- import { dirname as dirname23, join as join30 } from "node:path";
43329
+ import { existsSync as existsSync38, mkdirSync as mkdirSync7, renameSync as renameSync7, unlinkSync as unlinkSync5 } from "node:fs";
43330
+ import { dirname as dirname23, join as join29 } from "node:path";
43392
43331
  function defaultOpenCodeDbPath() {
43393
43332
  return getOpenCodeDatabasePath();
43394
43333
  }
43395
43334
  function defaultCortexkitDbPath() {
43396
- return join30(getMagicContextStorageDir(), "context.db");
43335
+ return join29(getMagicContextStorageDir(), "context.db");
43397
43336
  }
43398
43337
  function defaultPiSessionsRoot() {
43399
43338
  return getPiSessionsRoot();
43400
43339
  }
43401
43340
  function defaultFs() {
43402
- return { writeFileAtomic, unlinkSync: unlinkSync4, existsSync: existsSync39, renameSync: renameSync7, mkdirSync: mkdirSync7 };
43341
+ return { writeFileAtomic, unlinkSync: unlinkSync5, existsSync: existsSync38, renameSync: renameSync7, mkdirSync: mkdirSync7 };
43403
43342
  }
43404
43343
  function stmt(db, sql) {
43405
43344
  return db.prepare(sql);
@@ -43483,7 +43422,7 @@ function claimJournalIdentity(args) {
43483
43422
  migration_key, source_session_id, target_harness, pi_session_id,
43484
43423
  final_path, stage_path, content_sha256, phase, created_at
43485
43424
  ) VALUES (?, ?, ?, ?, ?, ?, '', 'staged', ?)
43486
- ON CONFLICT(migration_key) DO NOTHING`).run(args.migrationKey, args.sourceSessionId, args.targetHarness, piSessionId, args.finalPathFor(piSessionId), join30(args.stageDir, `${args.migrationKey}.jsonl`), args.now);
43425
+ ON CONFLICT(migration_key) DO NOTHING`).run(args.migrationKey, args.sourceSessionId, args.targetHarness, piSessionId, args.finalPathFor(piSessionId), join29(args.stageDir, `${args.migrationKey}.jsonl`), args.now);
43487
43426
  const row = readPendingMigration(args.db, args.migrationKey);
43488
43427
  if (!row) {
43489
43428
  throw new Error("migration journal row disappeared during insert; aborting migration");
@@ -43991,7 +43930,7 @@ function migrateOpenCodeSessionToPi(opts) {
43991
43930
  const provider = opts.provider ?? model.provider;
43992
43931
  const modelId = opts.modelId ?? model.modelId;
43993
43932
  const cwd = session.directory ?? session.path ?? process.cwd();
43994
- const outputDir = join30(piSessionsRoot, projectPathToPiDirSlug(cwd));
43933
+ const outputDir = join29(piSessionsRoot, projectPathToPiDirSlug(cwd));
43995
43934
  const targetHarness = opts.targetHarness ?? "pi";
43996
43935
  if (cortexkitDb !== null) {
43997
43936
  assertNoUnmigratedAuthority(cortexkitDb);
@@ -44018,8 +43957,8 @@ function migrateOpenCodeSessionToPi(opts) {
44018
43957
  migrationKey,
44019
43958
  sourceSessionId: session.id,
44020
43959
  targetHarness,
44021
- finalPathFor: (id) => join30(outputDir, `${formatPiFilenameTimestamp(now)}_${id}.jsonl`),
44022
- stageDir: join30(dirname23(piSessionsRoot), MIGRATION_STAGE_DIRNAME),
43960
+ finalPathFor: (id) => join29(outputDir, `${formatPiFilenameTimestamp(now)}_${id}.jsonl`),
43961
+ stageDir: join29(dirname23(piSessionsRoot), MIGRATION_STAGE_DIRNAME),
44023
43962
  now: now.getTime()
44024
43963
  });
44025
43964
  piSessionId = claimed.row.pi_session_id;
@@ -44028,7 +43967,7 @@ function migrateOpenCodeSessionToPi(opts) {
44028
43967
  journalResumed = claimed.resumed;
44029
43968
  } else {
44030
43969
  piSessionId = generateUuidV7(now);
44031
- finalPath = join30(outputDir, `${formatPiFilenameTimestamp(now)}_${piSessionId}.jsonl`);
43970
+ finalPath = join29(outputDir, `${formatPiFilenameTimestamp(now)}_${piSessionId}.jsonl`);
44032
43971
  stagePath = "";
44033
43972
  }
44034
43973
  const buildResult = buildPiEntries({
@@ -46377,12 +46316,12 @@ var init_store_ahead_refusal = __esm(() => {
46377
46316
 
46378
46317
  // ../plugin/src/hooks/magic-context/module-transport.ts
46379
46318
  import { realpathSync as realpathSync9 } from "node:fs";
46380
- import { join as join31 } from "node:path";
46319
+ import { join as join30 } from "node:path";
46381
46320
  function monotonicNow() {
46382
46321
  return monotonicClockForTests?.() ?? performance.now();
46383
46322
  }
46384
46323
  function getDefaultSubcConnectionFile() {
46385
- return join31(getDataDir(), "cortexkit", "run", "subc-connection.json");
46324
+ return join30(getDataDir(), "cortexkit", "run", "subc-connection.json");
46386
46325
  }
46387
46326
  function errorChainSome(error, predicate) {
46388
46327
  let current = error;
@@ -46991,9 +46930,9 @@ var init_module_transport = __esm(async () => {
46991
46930
  });
46992
46931
 
46993
46932
  // src/commands/migrate-session.ts
46994
- import { existsSync as existsSync40, realpathSync as realpathSync10 } from "node:fs";
46933
+ import { existsSync as existsSync39, realpathSync as realpathSync10 } from "node:fs";
46995
46934
  import { homedir as homedir20 } from "node:os";
46996
- import path7, { join as join32 } from "node:path";
46935
+ import path7, { join as join31 } from "node:path";
46997
46936
  function existingSessionColumns(db) {
46998
46937
  const rows = db.prepare("PRAGMA table_info(session)").all();
46999
46938
  return new Set(rows.map((r) => r.name).filter((n) => typeof n === "string"));
@@ -47174,14 +47113,14 @@ function defaultOpenCodeDbPath2() {
47174
47113
  return getOpenCodeDatabasePath();
47175
47114
  }
47176
47115
  function defaultContextDbPath() {
47177
- return join32(getMagicContextStorageDir(), "context.db");
47116
+ return join31(getMagicContextStorageDir(), "context.db");
47178
47117
  }
47179
47118
  function realDeps(opencodeDb, contextDb) {
47180
47119
  return {
47181
47120
  opencodeDb,
47182
47121
  contextDb,
47183
47122
  resolveIdentity: resolveProjectIdentity,
47184
- hasGitDir: (dir) => existsSync40(join32(dir, ".git")),
47123
+ hasGitDir: (dir) => existsSync39(join31(dir, ".git")),
47185
47124
  realpath: (p) => realpathSync10(p)
47186
47125
  };
47187
47126
  }
@@ -47259,8 +47198,8 @@ async function runMigrateSessionCli(args) {
47259
47198
  printMigrateSessionHelp();
47260
47199
  return 1;
47261
47200
  }
47262
- const expandedTo = toDir.startsWith("~") ? join32(homedir20(), toDir.slice(1).replace(/^[/\\]/, "")) : toDir;
47263
- if (!existsSync40(expandedTo)) {
47201
+ const expandedTo = toDir.startsWith("~") ? join31(homedir20(), toDir.slice(1).replace(/^[/\\]/, "")) : toDir;
47202
+ if (!existsSync39(expandedTo)) {
47264
47203
  console.error(`Target directory does not exist: ${expandedTo}`);
47265
47204
  return 1;
47266
47205
  }
@@ -47683,7 +47622,7 @@ var init_tick_failure = __esm(() => {
47683
47622
  });
47684
47623
 
47685
47624
  // ../pi-plugin/src/config/index.ts
47686
- import { existsSync as existsSync41 } from "node:fs";
47625
+ import { existsSync as existsSync40 } from "node:fs";
47687
47626
  function getProjectConfigPaths(cwd) {
47688
47627
  const basePath = cortexKitProjectConfigBasePath(cwd);
47689
47628
  return [`${basePath}.jsonc`, `${basePath}.json`];
@@ -47693,10 +47632,10 @@ function getUserConfigPaths() {
47693
47632
  return [`${basePath}.jsonc`, `${basePath}.json`];
47694
47633
  }
47695
47634
  function resolveFirstExisting(paths) {
47696
- return paths.find((path) => existsSync41(path));
47635
+ return paths.find((path) => existsSync40(path));
47697
47636
  }
47698
47637
  function resolvePiLegacyFallback(sources) {
47699
- return sources.find((source) => existsSync41(source.path)) ?? null;
47638
+ return sources.find((source) => existsSync40(source.path)) ?? null;
47700
47639
  }
47701
47640
  function loadConfigFile(path, scope) {
47702
47641
  let raw;
@@ -48010,7 +47949,7 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
48010
47949
  if (loaded)
48011
47950
  loadedFiles.push(loaded);
48012
47951
  }
48013
- const legacyProjectUnmigrated = !projectPath && !projectLegacyFallback && legacySources.project.some((source) => existsSync41(source.path));
47952
+ const legacyProjectUnmigrated = !projectPath && !projectLegacyFallback && legacySources.project.some((source) => existsSync40(source.path));
48014
47953
  const userPath = resolveFirstExisting(getUserConfigPaths());
48015
47954
  const userLegacyFallback = userPath ? null : resolvePiLegacyFallback(harnessLegacy.user);
48016
47955
  const userReadPath = userPath ?? userLegacyFallback?.path;
@@ -48019,7 +47958,7 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
48019
47958
  if (loaded)
48020
47959
  loadedFiles.push(loaded);
48021
47960
  }
48022
- const legacyUserUnmigrated = !userPath && !userLegacyFallback && legacySources.user.some((source) => existsSync41(source.path));
47961
+ const legacyUserUnmigrated = !userPath && !userLegacyFallback && legacySources.user.some((source) => existsSync40(source.path));
48023
47962
  if (userLegacyFallback) {
48024
47963
  warnings.push(`[user config] reading legacy config from ${userLegacyFallback.path} until migration completes; run \`npx @cortexkit/magic-context doctor\` to consolidate into the shared CortexKit location.`);
48025
47964
  } else if (legacyUserUnmigrated) {
@@ -48164,7 +48103,7 @@ var DATABASE_REPAIR_COMMAND = "bunx @cortexkit/magic-context@latest doctor repai
48164
48103
 
48165
48104
  // src/lib/github-issue.ts
48166
48105
  import { spawnSync as spawnSync7 } from "node:child_process";
48167
- import { readFileSync as readFileSync24 } from "node:fs";
48106
+ import { readFileSync as readFileSync23 } from "node:fs";
48168
48107
  function runGhCommand(args) {
48169
48108
  try {
48170
48109
  const result = spawnSync7("gh", args, {
@@ -48191,7 +48130,7 @@ function failed(result) {
48191
48130
  function submitGithubIssue(title, bodyPath, runner = runGhCommand) {
48192
48131
  let body;
48193
48132
  try {
48194
- body = readFileSync24(bodyPath, "utf-8");
48133
+ body = readFileSync23(bodyPath, "utf-8");
48195
48134
  } catch (error) {
48196
48135
  return {
48197
48136
  ok: false,
@@ -48604,7 +48543,6 @@ var init_issue_log_templates_generated = __esm(() => {
48604
48543
  "[magic-context] host stall profiler enabled: threshold \x01ms, sample interval \x01ms, backend v8, rotation \x01ms, reports in \x01",
48605
48544
  "rust transform deferred; the module is still applying an earlier transform of this session; attempting LKG replay: \x01",
48606
48545
  "[magic-context] WARN: workspace member has no workspace share_categories row; sharing no foreign memory categories",
48607
- "compartment trigger: force_band skipped — raw exists but protected head genuinely empty after emergency tail scale",
48608
48546
  "rust transform deferred; the module is still applying an earlier transform of this session; attempting LKG replay:",
48609
48547
  "prefix trim: boundary \x01; pass=defer; no in-pass trim applied (Hidden child first step requires a registered marker)",
48610
48548
  "[magic-context] [ERROR] compaction-marker: candidate worker unavailable \x01: \x01; marker unchanged, advancement deferred\x020p",
@@ -48645,6 +48583,7 @@ var init_issue_log_templates_generated = __esm(() => {
48645
48583
  "compartment injection entering degraded mode: boundary \x01 not in visible messages (consecutive degraded passes: \x01)\x021s",
48646
48584
  "auto-search: decision outcome=timeout lanes=\x01 nearMisses=\x01 threshold=\x01 pool=\x01 rows=\x01 workerStarted=\x01 peek=\x01 elapsedMs=\x01",
48647
48585
  "[auto-update-checker] Explicit @latest leaves the active package unpinned; OpenCode may delete it mid-session.",
48586
+ "compartment trigger: force_band skipped — no protected head meets summary admission after emergency tail scale",
48648
48587
  "historian: refusing to publish over a stale protected-tail snapshot (was: \x01); ending the run without publishing",
48649
48588
  "ERROR: compaction marker disabled: incompatible host binding harness=\x01 arity=\x01 getEntry=\x01; leaving marker pending",
48650
48589
  "heuristic cleanup: dropped \x01 tool tags, stale ctx_reduce=\x01, deduplicated \x01 tool calls, dropped \x01 system injections",
@@ -49794,6 +49733,7 @@ var init_issue_log_templates_generated = __esm(() => {
49794
49733
  "ctx_reduce permission read before freeze failed (fail-open):",
49795
49734
  "historian skipped: compartment lease held by another process",
49796
49735
  "protected-tail stored-token map unavailable (live fallback):",
49736
+ "todowrite todos could not be read; cleared the todo snapshot",
49797
49737
  "transform refused degraded pass site=flushed-status-failure:",
49798
49738
  "WARN: message_end: stripTagPrefixFromAssistantMessage threw:",
49799
49739
  "stored \x01 primer candidate occurrence(s) (chunk-span fallback)",
@@ -50421,6 +50361,7 @@ var init_issue_log_templates_generated = __esm(() => {
50421
50361
  "channel2 delivery wrapper failed (ignored): \x01",
50422
50362
  "channel2 fold-cycle reset failed (ignored): \x01",
50423
50363
  "channel2 U-collapse reset failed (ignored): \x01",
50364
+ "Failed to ensure project artifact gitignore \x01",
50424
50365
  "lkg_fit_basis=provider_input measured_input=\x01",
50425
50366
  "mc-module: aborting historian trigger for \x01: \x01",
50426
50367
  "Pi note-nudge delivery skipped wire append: \x01",
@@ -50436,6 +50377,7 @@ var init_issue_log_templates_generated = __esm(() => {
50436
50377
  "channel2 delivery wrapper failed (ignored):",
50437
50378
  "channel2 fold-cycle reset failed (ignored):",
50438
50379
  "channel2 U-collapse reset failed (ignored):",
50380
+ "Failed to ensure project artifact gitignore",
50439
50381
  "historian skip: internal drain budget spent",
50440
50382
  "historian trigger eval: in-flight, skipping",
50441
50383
  "historian two-pass: running editor on draft",
@@ -51233,9 +51175,9 @@ var init_issue_log_templates_generated = __esm(() => {
51233
51175
  });
51234
51176
 
51235
51177
  // src/lib/log-lines.ts
51236
- import { existsSync as existsSync42, readFileSync as readFileSync25, statSync as statSync22 } from "node:fs";
51178
+ import { existsSync as existsSync41, readFileSync as readFileSync24, statSync as statSync22 } from "node:fs";
51237
51179
  import { tmpdir as tmpdir3 } from "node:os";
51238
- import { join as join33 } from "node:path";
51180
+ import { join as join32 } from "node:path";
51239
51181
  function tokenize(input, limit = Number.POSITIVE_INFINITY) {
51240
51182
  const tokens = [];
51241
51183
  let index = 0;
@@ -51521,20 +51463,20 @@ function parseLogLine(line) {
51521
51463
  }
51522
51464
  function getMagicContextLogPaths(harness, options = {}) {
51523
51465
  const override = options.override === undefined ? process.env.MAGIC_CONTEXT_LOG_PATH?.trim() : options.override?.trim();
51524
- const storageLogs = join33(options.storageDir ?? getMagicContextStorageDir(), "logs");
51466
+ const storageLogs = join32(options.storageDir ?? getMagicContextStorageDir(), "logs");
51525
51467
  return [
51526
51468
  ...override ? [override] : [],
51527
- join33(options.tempDir ?? tmpdir3(), harness, "magic-context", "magic-context.log"),
51528
- join33(storageLogs, `magic-context.${harness}.log`),
51529
- join33(storageLogs, "magic-context.log")
51469
+ join32(options.tempDir ?? tmpdir3(), harness, "magic-context", "magic-context.log"),
51470
+ join32(storageLogs, `magic-context.${harness}.log`),
51471
+ join32(storageLogs, "magic-context.log")
51530
51472
  ].filter((path, index, paths) => paths.indexOf(path) === index);
51531
51473
  }
51532
51474
  function inspectLogFile(path) {
51533
- if (!existsSync42(path)) {
51475
+ if (!existsSync41(path)) {
51534
51476
  return { path, exists: false, sizeKb: 0, lineCount: 0, grammar: "unknown" };
51535
51477
  }
51536
51478
  try {
51537
- const content = readFileSync25(path, "utf8");
51479
+ const content = readFileSync24(path, "utf8");
51538
51480
  const lines = content.split(/\r?\n/).filter((line) => line.length > 0);
51539
51481
  const grammars = new Set(lines.flatMap((line) => {
51540
51482
  const parsed = parseLogLine(line);
@@ -51561,7 +51503,7 @@ function readLogLines(files) {
51561
51503
  return [];
51562
51504
  try {
51563
51505
  let precedingTimestamp = "";
51564
- return readFileSync25(file.path, "utf8").split(/\r?\n/).filter((line) => line.length > 0).map((line, lineIndex) => {
51506
+ return readFileSync24(file.path, "utf8").split(/\r?\n/).filter((line) => line.length > 0).map((line, lineIndex) => {
51565
51507
  precedingTimestamp = parseLogLine(line)?.ts ?? precedingTimestamp;
51566
51508
  return { line, timestamp: precedingTimestamp, fileIndex, lineIndex };
51567
51509
  });
@@ -52169,8 +52111,8 @@ var init_issue_body = __esm(() => {
52169
52111
  });
52170
52112
 
52171
52113
  // src/lib/omp-hide-secrets.ts
52172
- import { existsSync as existsSync43, readdirSync as readdirSync9, readFileSync as readFileSync26, statSync as statSync23 } from "node:fs";
52173
- import { join as join34, resolve as resolve17 } from "node:path";
52114
+ import { existsSync as existsSync42, readdirSync as readdirSync9, readFileSync as readFileSync25, statSync as statSync23 } from "node:fs";
52115
+ import { join as join33, resolve as resolve17 } from "node:path";
52174
52116
  function stripYamlComment(line) {
52175
52117
  let quote = null;
52176
52118
  for (let index = 0;index < line.length; index += 1) {
@@ -52293,7 +52235,7 @@ function readHideSecretsFromJson(text) {
52293
52235
  function readSource(layer, path, format) {
52294
52236
  let text;
52295
52237
  try {
52296
- text = readFileSync26(path, "utf-8");
52238
+ text = readFileSync25(path, "utf-8");
52297
52239
  } catch (error) {
52298
52240
  const code = error.code;
52299
52241
  return {
@@ -52321,22 +52263,22 @@ function isNonEmptyDirectory(path) {
52321
52263
  function collectHideSecretsSources(cwd, home = envFirstHomeDir()) {
52322
52264
  const sources = [];
52323
52265
  const agentDir = getOmpAgentDir();
52324
- const mainConfig = ["config.yml", "config.yaml"].map((name) => join34(agentDir, name)).find((path) => existsSync43(path));
52266
+ const mainConfig = ["config.yml", "config.yaml"].map((name) => join33(agentDir, name)).find((path) => existsSync42(path));
52325
52267
  if (mainConfig)
52326
52268
  sources.push(readSource("user", mainConfig, "yaml"));
52327
- const projectDir = join34(cwd, ".omp");
52269
+ const projectDir = join33(cwd, ".omp");
52328
52270
  if (resolve17(cwd) !== resolve17(home) && isNonEmptyDirectory(projectDir)) {
52329
52271
  for (const [name, format] of [
52330
52272
  ["settings.json", "json"],
52331
52273
  ["config.yml", "yaml"]
52332
52274
  ]) {
52333
- const path = join34(projectDir, name);
52334
- if (existsSync43(path))
52275
+ const path = join33(projectDir, name);
52276
+ if (existsSync42(path))
52335
52277
  sources.push(readSource("project", path, format));
52336
52278
  }
52337
52279
  }
52338
52280
  for (const path of getOmpConfigOverlayPaths(cwd)) {
52339
- if (existsSync43(path))
52281
+ if (existsSync42(path))
52340
52282
  sources.push(readSource("overlay", path, "yaml"));
52341
52283
  }
52342
52284
  return sources;
@@ -52394,9 +52336,9 @@ var init_omp_hide_secrets = __esm(() => {
52394
52336
 
52395
52337
  // src/commands/doctor-omp.ts
52396
52338
  import { execFileSync as execFileSync8, spawnSync as spawnSync8 } from "node:child_process";
52397
- import { existsSync as existsSync44, readFileSync as readFileSync27 } from "node:fs";
52339
+ import { existsSync as existsSync43, readFileSync as readFileSync26 } from "node:fs";
52398
52340
  import { createRequire as createRequire3 } from "node:module";
52399
- import { isAbsolute as isAbsolute8, join as join35, resolve as resolve18 } from "node:path";
52341
+ import { isAbsolute as isAbsolute8, join as join34, resolve as resolve18 } from "node:path";
52400
52342
  function parseSemver(value) {
52401
52343
  const match = value?.match(/(\d+)\.(\d+)\.(\d+)/);
52402
52344
  return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
@@ -52438,10 +52380,10 @@ function selfVersion() {
52438
52380
  return "unknown";
52439
52381
  }
52440
52382
  function readConfig2(path) {
52441
- if (!existsSync44(path))
52383
+ if (!existsSync43(path))
52442
52384
  return {};
52443
52385
  try {
52444
- const parsed = import_comment_json8.parse(readFileSync27(path, "utf-8"));
52386
+ const parsed = import_comment_json8.parse(readFileSync26(path, "utf-8"));
52445
52387
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? {} : { error: "top level is not an object" };
52446
52388
  } catch (error) {
52447
52389
  return { error: error instanceof Error ? error.message : String(error) };
@@ -52451,7 +52393,7 @@ function pluginDeclaresOmp(path) {
52451
52393
  if (!path)
52452
52394
  return null;
52453
52395
  try {
52454
- const pkg = JSON.parse(readFileSync27(join35(path, "package.json"), "utf-8"));
52396
+ const pkg = JSON.parse(readFileSync26(join34(path, "package.json"), "utf-8"));
52455
52397
  return Array.isArray(pkg.omp?.extensions) || Array.isArray(pkg.pi?.extensions);
52456
52398
  } catch {
52457
52399
  return null;
@@ -52540,7 +52482,7 @@ async function runHealthChecks(options) {
52540
52482
  }
52541
52483
  }
52542
52484
  const userConfigPath = getOmpUserConfigPath();
52543
- if (!existsSync44(userConfigPath)) {
52485
+ if (!existsSync43(userConfigPath)) {
52544
52486
  add(results, "warn", `No Magic Context user config at ${userConfigPath}`);
52545
52487
  repairPlan.writeUserConfig = true;
52546
52488
  } else {
@@ -52557,12 +52499,12 @@ async function runHealthChecks(options) {
52557
52499
  for (const warning of loaded.warnings.slice(0, 5))
52558
52500
  add(results, "warn", warning);
52559
52501
  const storage = getMagicContextStorageResolution();
52560
- const dbPath = join35(storage.path, "context.db");
52502
+ const dbPath = join34(storage.path, "context.db");
52561
52503
  if (isMagicContextStorageOutsideEngram(storage.path)) {
52562
52504
  add(results, "warn", `Magic Context storage is at ${storage.path}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
52563
52505
  }
52564
52506
  add(results, "info", `Shared storage: ${storage.path} (source: ${storage.source})`);
52565
- if (!existsSync44(dbPath))
52507
+ if (!existsSync43(dbPath))
52566
52508
  add(results, "info", `Shared context DB will be created at ${dbPath}`);
52567
52509
  else {
52568
52510
  let db = null;
@@ -52627,7 +52569,7 @@ function writeDefaultConfig(path) {
52627
52569
  }
52628
52570
  async function repair(plan, deps, prompts, cwd) {
52629
52571
  let fixed = 0;
52630
- if (plan.writeUserConfig && !existsSync44(getOmpUserConfigPath())) {
52572
+ if (plan.writeUserConfig && !existsSync43(getOmpUserConfigPath())) {
52631
52573
  writeDefaultConfig(getOmpUserConfigPath());
52632
52574
  prompts.log.success(`Wrote default Magic Context config to ${getOmpUserConfigPath()}`);
52633
52575
  fixed += 1;
@@ -52740,7 +52682,7 @@ function runGhCommandWithDeps(deps, args) {
52740
52682
  async function runIssueFlow(options) {
52741
52683
  if (options.reportPath) {
52742
52684
  const report = await runHealthChecks({ ...options, quiet: true });
52743
- const path = isAbsolute8(options.reportPath) ? options.reportPath : join35(options.cwd, options.reportPath);
52685
+ const path = isAbsolute8(options.reportPath) ? options.reportPath : join34(options.cwd, options.reportPath);
52744
52686
  const bundle = writeOmpIssueReport(path, ompIssueBody("Generated non-interactively by `doctor --issue --report`.", report, readLogLines(report.logFiles), null, options.cwd));
52745
52687
  options.prompts.log.success(bundle.fullPath ? `Sanitized report written to ${bundle.path}; full report at ${bundle.fullPath}` : `Sanitized report written to ${bundle.path}`);
52746
52688
  return 0;
@@ -52767,7 +52709,7 @@ async function runIssueFlow(options) {
52767
52709
  ]);
52768
52710
  sessionFilter = choice === "__all__" ? null : choice;
52769
52711
  }
52770
- const path = join35(options.cwd, `magic-context-omp-issue-${timestamp2(options.deps.now())}.md`);
52712
+ const path = join34(options.cwd, `magic-context-omp-issue-${timestamp2(options.deps.now())}.md`);
52771
52713
  const bundle = writeOmpIssueReport(path, ompIssueBody(description, report, logLines, sessionFilter, options.cwd));
52772
52714
  options.prompts.log.success(bundle.fullPath ? `Sanitized report written to ${bundle.path}; full report at ${bundle.fullPath}` : `Sanitized report written to ${bundle.path}`);
52773
52715
  if (await options.prompts.confirm("Submit this issue on GitHub now?", false)) {
@@ -53737,12 +53679,12 @@ function listShadowBackfillStalls(db, projectIdentity) {
53737
53679
  var SHADOW_BACKFILL_PROVENANCE_KEY = "_magicContextShadowBackfill";
53738
53680
 
53739
53681
  // ../plugin/src/shared/auto-update-provenance.ts
53740
- import { existsSync as existsSync45, readFileSync as readFileSync28 } from "node:fs";
53682
+ import { existsSync as existsSync44, readFileSync as readFileSync27 } from "node:fs";
53741
53683
  function readAutoUpdateCheckState(path) {
53742
- if (!existsSync45(path))
53684
+ if (!existsSync44(path))
53743
53685
  return null;
53744
53686
  try {
53745
- const value = JSON.parse(readFileSync28(path, "utf-8"));
53687
+ const value = JSON.parse(readFileSync27(path, "utf-8"));
53746
53688
  if (!value || typeof value !== "object" || Array.isArray(value))
53747
53689
  return null;
53748
53690
  const raw = value;
@@ -53770,14 +53712,14 @@ var init_auto_update_provenance = () => {};
53770
53712
  // ../plugin/src/shared/tui-config.ts
53771
53713
  import {
53772
53714
  chmodSync as chmodSync4,
53773
- existsSync as existsSync46,
53715
+ existsSync as existsSync45,
53774
53716
  mkdirSync as mkdirSync8,
53775
- readFileSync as readFileSync29,
53717
+ readFileSync as readFileSync28,
53776
53718
  renameSync as renameSync8,
53777
53719
  statSync as statSync24,
53778
53720
  writeFileSync as writeFileSync8
53779
53721
  } from "node:fs";
53780
- import { dirname as dirname24, join as join36 } from "node:path";
53722
+ import { dirname as dirname24, join as join35 } from "node:path";
53781
53723
  function pluginEntryId(entry) {
53782
53724
  if (typeof entry === "string")
53783
53725
  return entry;
@@ -53818,11 +53760,11 @@ function writeTuiConfigAtomic(configPath, config) {
53818
53760
  }
53819
53761
  function resolveTuiConfigPath(configDirOverride) {
53820
53762
  const configDir = configDirOverride ?? getOpenCodeConfigPaths({ binary: "opencode" }).configDir;
53821
- const jsoncPath = join36(configDir, "tui.jsonc");
53822
- const jsonPath = join36(configDir, "tui.json");
53823
- if (existsSync46(jsoncPath))
53763
+ const jsoncPath = join35(configDir, "tui.jsonc");
53764
+ const jsonPath = join35(configDir, "tui.json");
53765
+ if (existsSync45(jsoncPath))
53824
53766
  return jsoncPath;
53825
- if (existsSync46(jsonPath))
53767
+ if (existsSync45(jsonPath))
53826
53768
  return jsonPath;
53827
53769
  return jsoncPath;
53828
53770
  }
@@ -53830,8 +53772,8 @@ function ensureTuiPluginEntry(options = {}) {
53830
53772
  try {
53831
53773
  const configPath = resolveTuiConfigPath(options.configDir);
53832
53774
  let config = {};
53833
- if (existsSync46(configPath)) {
53834
- const raw = readFileSync29(configPath, "utf-8");
53775
+ if (existsSync45(configPath)) {
53776
+ const raw = readFileSync28(configPath, "utf-8");
53835
53777
  config = import_comment_json9.parse(raw) ?? {};
53836
53778
  }
53837
53779
  const plugins = Array.isArray(config.plugin) ? [...config.plugin] : [];
@@ -53883,9 +53825,9 @@ var init_tui_config = __esm(() => {
53883
53825
  });
53884
53826
 
53885
53827
  // src/lib/diagnostics-opencode.ts
53886
- import { existsSync as existsSync47, readdirSync as readdirSync10, readFileSync as readFileSync30, statSync as statSync25 } from "node:fs";
53828
+ import { existsSync as existsSync46, readdirSync as readdirSync10, readFileSync as readFileSync29, statSync as statSync25 } from "node:fs";
53887
53829
  import { createRequire as createRequire4 } from "node:module";
53888
- import { join as join37 } from "node:path";
53830
+ import { join as join36 } from "node:path";
53889
53831
  function getSelfVersion() {
53890
53832
  const require2 = createRequire4(import.meta.url);
53891
53833
  for (const relPath of ["../../package.json", "../package.json"]) {
@@ -53900,7 +53842,7 @@ function getSelfVersion() {
53900
53842
  }
53901
53843
  function readLegacyCachedVersion(root) {
53902
53844
  try {
53903
- const pkg = JSON.parse(readFileSync30(getOpenCodePluginPackageJsonPath(root), "utf-8"));
53845
+ const pkg = JSON.parse(readFileSync29(getOpenCodePluginPackageJsonPath(root), "utf-8"));
53904
53846
  return typeof pkg.version === "string" ? pkg.version : undefined;
53905
53847
  } catch {
53906
53848
  return;
@@ -53909,7 +53851,7 @@ function readLegacyCachedVersion(root) {
53909
53851
  function collectOpenCodePluginCacheReport(hostGeneration, opencodeConfig) {
53910
53852
  const installs = [];
53911
53853
  for (const root of getOpenCodePluginCacheRoots()) {
53912
- if (!existsSync47(root))
53854
+ if (!existsSync46(root))
53913
53855
  continue;
53914
53856
  const spec = root.endsWith("@latest") ? "latest" : "(bare)";
53915
53857
  installs.push({
@@ -53943,7 +53885,7 @@ function getStorageResolution() {
53943
53885
  }
53944
53886
  function fileSize(path) {
53945
53887
  try {
53946
- return existsSync47(path) ? statSync25(path).size : 0;
53888
+ return existsSync46(path) ? statSync25(path).size : 0;
53947
53889
  } catch {
53948
53890
  return 0;
53949
53891
  }
@@ -53955,10 +53897,10 @@ function sanitizeValue(value) {
53955
53897
  return sanitizeConfigValue(value);
53956
53898
  }
53957
53899
  function readConfig3(path) {
53958
- if (!existsSync47(path))
53900
+ if (!existsSync46(path))
53959
53901
  return { value: null };
53960
53902
  try {
53961
- const raw = readFileSync30(path, "utf-8");
53903
+ const raw = readFileSync29(path, "utf-8");
53962
53904
  const value = import_comment_json10.parse(raw);
53963
53905
  return { value };
53964
53906
  } catch (error) {
@@ -53983,7 +53925,7 @@ function configHasPluginEntry(config) {
53983
53925
  }
53984
53926
  function parseHistorianDumpMeta(path) {
53985
53927
  try {
53986
- const xml = readFileSync30(path, "utf-8");
53928
+ const xml = readFileSync29(path, "utf-8");
53987
53929
  const parsed = parseCompartmentOutput(xml);
53988
53930
  const factCountByCategory = {};
53989
53931
  for (const fact of parsed.facts) {
@@ -54016,11 +53958,11 @@ function parseHistorianDumpMeta(path) {
54016
53958
  }
54017
53959
  }
54018
53960
  function listDumpsInDir(dir, limit) {
54019
- if (!existsSync47(dir))
53961
+ if (!existsSync46(dir))
54020
53962
  return { count: 0, recent: [] };
54021
53963
  try {
54022
53964
  const entries = readdirSync10(dir).filter((name) => name.endsWith(".xml")).map((name) => {
54023
- const stat = statSync25(join37(dir, name));
53965
+ const stat = statSync25(join36(dir, name));
54024
53966
  return {
54025
53967
  name,
54026
53968
  mtime: stat.mtimeMs,
@@ -54029,7 +53971,7 @@ function listDumpsInDir(dir, limit) {
54029
53971
  }).sort((a, b) => b.mtime - a.mtime);
54030
53972
  const now = Date.now();
54031
53973
  const recent = entries.slice(0, limit).map((entry) => {
54032
- const meta = parseHistorianDumpMeta(join37(dir, entry.name));
53974
+ const meta = parseHistorianDumpMeta(join36(dir, entry.name));
54033
53975
  const summary = {
54034
53976
  name: entry.name,
54035
53977
  ageMinutes: Math.round((now - entry.mtime) / 60000),
@@ -54140,7 +54082,7 @@ function collectRecentSessionsFromDatabase(database) {
54140
54082
  });
54141
54083
  }
54142
54084
  async function collectDatabaseRows(path, read) {
54143
- if (!existsSync47(path))
54085
+ if (!existsSync46(path))
54144
54086
  return { available: false, reason: "path missing" };
54145
54087
  let backend;
54146
54088
  try {
@@ -54172,7 +54114,7 @@ async function collectRecentSessions(resolution, hostGeneration) {
54172
54114
  });
54173
54115
  }
54174
54116
  async function collectHistorianFailures(storageDirPath) {
54175
- return collectDatabaseRows(join37(storageDirPath, "context.db"), (db) => {
54117
+ return collectDatabaseRows(join36(storageDirPath, "context.db"), (db) => {
54176
54118
  const rows = db.prepare("SELECT session_id, historian_failure_count, historian_last_error, historian_last_failure_at FROM session_meta WHERE historian_failure_count > 0 ORDER BY historian_last_failure_at DESC LIMIT 10").all();
54177
54119
  return rows.map((row) => {
54178
54120
  const sessionId = typeof row.session_id === "string" ? row.session_id : "<unknown>";
@@ -54185,7 +54127,7 @@ async function collectHistorianFailures(storageDirPath) {
54185
54127
  });
54186
54128
  }
54187
54129
  async function collectHistorianRuns(storageDirPath) {
54188
- return collectDatabaseRows(join37(storageDirPath, "context.db"), (db) => {
54130
+ return collectDatabaseRows(join36(storageDirPath, "context.db"), (db) => {
54189
54131
  const aggRows = db.prepare(`SELECT session_id,
54190
54132
  COUNT(*) AS total,
54191
54133
  SUM(CASE WHEN status='success' THEN 1 ELSE 0 END) AS success,
@@ -54240,7 +54182,7 @@ async function collectDiagnostics() {
54240
54182
  const magicContextConfig = readConfig3(configPaths.magicContextConfig);
54241
54183
  const storageResolution = getStorageResolution();
54242
54184
  const storageDirPath = storageResolution.path;
54243
- const contextDbPath = join37(storageDirPath, "context.db");
54185
+ const contextDbPath = join36(storageDirPath, "context.db");
54244
54186
  let compactionEnabled = false;
54245
54187
  try {
54246
54188
  compactionEnabled = isCompactionEnabled(loadPluginConfig(process.cwd()));
@@ -54272,7 +54214,7 @@ async function collectDiagnostics() {
54272
54214
  opencodeConfigHasPlugin: configHasPluginEntry(opencodeConfig.value),
54273
54215
  tuiConfigHasPlugin: configHasPluginEntry(tuiConfig.value),
54274
54216
  magicContextConfig: {
54275
- exists: existsSync47(configPaths.magicContextConfig),
54217
+ exists: existsSync46(configPaths.magicContextConfig),
54276
54218
  ...magicContextConfig.error ? { parseError: magicContextConfig.error } : {},
54277
54219
  flags: sanitizeValue(magicContextConfig.value ?? {}) ?? {}
54278
54220
  },
@@ -54280,7 +54222,7 @@ async function collectDiagnostics() {
54280
54222
  storageDir: {
54281
54223
  path: storageDirPath,
54282
54224
  source: storageResolution.source,
54283
- exists: existsSync47(storageDirPath),
54225
+ exists: existsSync46(storageDirPath),
54284
54226
  contextDbSizeBytes: fileSize(contextDbPath)
54285
54227
  },
54286
54228
  openCodeDatabase: {
@@ -54550,9 +54492,9 @@ var init_embedding_local = __esm(async () => {
54550
54492
 
54551
54493
  // src/lib/embedding-runtime.ts
54552
54494
  import { spawnSync as spawnSync9 } from "node:child_process";
54553
- import { existsSync as existsSync48, readFileSync as readFileSync31 } from "node:fs";
54495
+ import { existsSync as existsSync47, readFileSync as readFileSync30 } from "node:fs";
54554
54496
  import { createRequire as createRequire5 } from "node:module";
54555
- import { dirname as dirname25, join as join38, sep as sep2 } from "node:path";
54497
+ import { dirname as dirname25, join as join37, sep as sep2 } from "node:path";
54556
54498
  function describeError(error) {
54557
54499
  const message = error instanceof Error ? error.message : String(error ?? "unknown error");
54558
54500
  const code = error?.code;
@@ -54694,11 +54636,11 @@ function expectedBinaryRelPath(platform, arch) {
54694
54636
  const supportedArch = arch === "x64" || arch === "arm64";
54695
54637
  if (!supportedPlatform || !supportedArch)
54696
54638
  return null;
54697
- return join38("bin", "napi-v6", platform, arch, "onnxruntime_binding.node");
54639
+ return join37("bin", "napi-v6", platform, arch, "onnxruntime_binding.node");
54698
54640
  }
54699
54641
  function onnxRuntimeNodeVersion(packageDir) {
54700
54642
  try {
54701
- const parsed = JSON.parse(readFileSync31(join38(packageDir, "package.json"), "utf8"));
54643
+ const parsed = JSON.parse(readFileSync30(join37(packageDir, "package.json"), "utf8"));
54702
54644
  return typeof parsed.version === "string" ? parsed.version : undefined;
54703
54645
  } catch {
54704
54646
  return;
@@ -54747,7 +54689,7 @@ function formatLocalEmbeddingRuntimeWasmSelected(status) {
54747
54689
  function requireNodeWasmBundle(probe, candidates) {
54748
54690
  if (probe.state === "failed")
54749
54691
  return probe;
54750
- const bundlePath = candidates.find((candidate) => existsSync48(candidate));
54692
+ const bundlePath = candidates.find((candidate) => existsSync47(candidate));
54751
54693
  return bundlePath ? probe : {
54752
54694
  state: "failed",
54753
54695
  reason: `functional Node WASM Transformers bundle is missing (checked ${candidates.join(", ")})`
@@ -54755,13 +54697,13 @@ function requireNodeWasmBundle(probe, candidates) {
54755
54697
  }
54756
54698
  function nodeWasmBundleCandidates(installRoot) {
54757
54699
  return [
54758
- join38(installRoot, "dist", "transformers-node-wasm.js"),
54759
- join38(installRoot, "node_modules", "@cortexkit", "opencode-magic-context", "dist", "transformers-node-wasm.js"),
54760
- join38(installRoot, "node_modules", "@cortexkit", "pi-magic-context", "dist", "transformers-node-wasm.js")
54700
+ join37(installRoot, "dist", "transformers-node-wasm.js"),
54701
+ join37(installRoot, "node_modules", "@cortexkit", "opencode-magic-context", "dist", "transformers-node-wasm.js"),
54702
+ join37(installRoot, "node_modules", "@cortexkit", "pi-magic-context", "dist", "transformers-node-wasm.js")
54761
54703
  ];
54762
54704
  }
54763
54705
  function probeWasmRuntimeAt(installRoot) {
54764
- const requireFn = createRequire5(join38(installRoot, "package.json"));
54706
+ const requireFn = createRequire5(join37(installRoot, "package.json"));
54765
54707
  return requireNodeWasmBundle(probeWasmRuntimeFromRequire(requireFn), nodeWasmBundleCandidates(installRoot));
54766
54708
  }
54767
54709
  function checkLocalEmbeddingRuntimeAt(installRoot, platform = process.platform, arch = process.arch, runtimePreference = "auto", host) {
@@ -54770,9 +54712,9 @@ function checkLocalEmbeddingRuntimeAt(installRoot, platform = process.platform,
54770
54712
  const wasm = probeWasmRuntimeAt(installRoot);
54771
54713
  return wasm.state === "ok" ? { state: "wasm-selected", wasmPath: wasm.wasmPath } : { state: "wasm-broken", wasmReason: wasm.reason };
54772
54714
  }
54773
- const packageDir = join38(installRoot, "node_modules", "onnxruntime-node");
54715
+ const packageDir = join37(installRoot, "node_modules", "onnxruntime-node");
54774
54716
  let native;
54775
- if (!existsSync48(join38(packageDir, "package.json"))) {
54717
+ if (!existsSync47(join37(packageDir, "package.json"))) {
54776
54718
  native = { state: "package-missing", packageDir };
54777
54719
  } else {
54778
54720
  const rel = expectedBinaryRelPath(platform, arch);
@@ -54782,8 +54724,8 @@ function checkLocalEmbeddingRuntimeAt(installRoot, platform = process.platform,
54782
54724
  binaryPath: packageDir
54783
54725
  };
54784
54726
  } else {
54785
- const binaryPath = join38(packageDir, rel);
54786
- native = existsSync48(binaryPath) ? probeOnnxRuntimeNodeLoad(packageDir) ?? { state: "ok", binaryPath } : {
54727
+ const binaryPath = join37(packageDir, rel);
54728
+ native = existsSync47(binaryPath) ? probeOnnxRuntimeNodeLoad(packageDir) ?? { state: "ok", binaryPath } : {
54787
54729
  state: "binary-missing",
54788
54730
  packageDir,
54789
54731
  expectedBinary: binaryPath,
@@ -54794,7 +54736,7 @@ function checkLocalEmbeddingRuntimeAt(installRoot, platform = process.platform,
54794
54736
  return withWasmFallback(native, () => probeWasmRuntimeAt(installRoot));
54795
54737
  }
54796
54738
  function checkLocalEmbeddingRuntime(installRoots, platform = process.platform, arch = process.arch, runtimePreference = "auto", host) {
54797
- const existing = installRoots.filter((root) => existsSync48(root));
54739
+ const existing = installRoots.filter((root) => existsSync47(root));
54798
54740
  if (existing.length === 0) {
54799
54741
  return {
54800
54742
  state: "unknown",
@@ -54824,15 +54766,15 @@ function packageDirFromResolved(resolvedPath, packageName) {
54824
54766
  }
54825
54767
  function probeWasmRuntimeByResolution(pluginDir) {
54826
54768
  try {
54827
- const reqPlugin = createRequire5(join38(pluginDir, "package.json"));
54769
+ const reqPlugin = createRequire5(join37(pluginDir, "package.json"));
54828
54770
  const direct = probeWasmRuntimeFromRequire(reqPlugin);
54829
54771
  let probe = direct;
54830
54772
  if (direct.state === "failed" && direct.reason.startsWith("onnxruntime-web is not resolvable")) {
54831
54773
  const tfResolved = reqPlugin.resolve("@huggingface/transformers");
54832
54774
  const tfDir = packageDirFromResolved(tfResolved, "@huggingface/transformers");
54833
- probe = probeWasmRuntimeFromRequire(createRequire5(join38(tfDir, "package.json")));
54775
+ probe = probeWasmRuntimeFromRequire(createRequire5(join37(tfDir, "package.json")));
54834
54776
  }
54835
- return requireNodeWasmBundle(probe, [join38(pluginDir, "dist", "transformers-node-wasm.js")]);
54777
+ return requireNodeWasmBundle(probe, [join37(pluginDir, "dist", "transformers-node-wasm.js")]);
54836
54778
  } catch (error) {
54837
54779
  return {
54838
54780
  state: "failed",
@@ -54841,7 +54783,7 @@ function probeWasmRuntimeByResolution(pluginDir) {
54841
54783
  }
54842
54784
  }
54843
54785
  function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.platform, arch = process.arch, runtimePreference = "auto", host) {
54844
- if (!existsSync48(join38(pluginDir, "package.json"))) {
54786
+ if (!existsSync47(join37(pluginDir, "package.json"))) {
54845
54787
  return { state: "unknown", reason: "plugin package dir not found" };
54846
54788
  }
54847
54789
  const selectedRuntime = resolveLocalEmbeddingWorkerRuntime(runtimePreference, host);
@@ -54852,13 +54794,13 @@ function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.pl
54852
54794
  let onnxDir = null;
54853
54795
  let resolveError;
54854
54796
  try {
54855
- const reqPlugin = createRequire5(join38(pluginDir, "package.json"));
54797
+ const reqPlugin = createRequire5(join37(pluginDir, "package.json"));
54856
54798
  try {
54857
54799
  onnxDir = packageDirFromResolved(reqPlugin.resolve("onnxruntime-node"), "onnxruntime-node");
54858
54800
  } catch {
54859
54801
  const tfResolved = reqPlugin.resolve("@huggingface/transformers");
54860
54802
  const tfDir = packageDirFromResolved(tfResolved, "@huggingface/transformers");
54861
- const reqTf = createRequire5(join38(tfDir, "package.json"));
54803
+ const reqTf = createRequire5(join37(tfDir, "package.json"));
54862
54804
  onnxDir = packageDirFromResolved(reqTf.resolve("onnxruntime-node"), "onnxruntime-node");
54863
54805
  }
54864
54806
  } catch (error) {
@@ -54866,7 +54808,7 @@ function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.pl
54866
54808
  if (resolveError === "ERR_MODULE_NOT_FOUND" || resolveError === "MODULE_NOT_FOUND") {
54867
54809
  return withWasmFallback({
54868
54810
  state: "package-missing",
54869
- packageDir: join38(pluginDir, "node_modules", "onnxruntime-node")
54811
+ packageDir: join37(pluginDir, "node_modules", "onnxruntime-node")
54870
54812
  }, () => probeWasmRuntimeByResolution(pluginDir));
54871
54813
  }
54872
54814
  return {
@@ -54882,8 +54824,8 @@ function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.pl
54882
54824
  if (rel === null) {
54883
54825
  native = probeOnnxRuntimeNodeLoad(onnxDir) ?? { state: "ok", binaryPath: onnxDir };
54884
54826
  } else {
54885
- const binaryPath = join38(onnxDir, rel);
54886
- native = existsSync48(binaryPath) ? probeOnnxRuntimeNodeLoad(onnxDir) ?? { state: "ok", binaryPath } : {
54827
+ const binaryPath = join37(onnxDir, rel);
54828
+ native = existsSync47(binaryPath) ? probeOnnxRuntimeNodeLoad(onnxDir) ?? { state: "ok", binaryPath } : {
54887
54829
  state: "binary-missing",
54888
54830
  packageDir: onnxDir,
54889
54831
  expectedBinary: binaryPath,
@@ -54919,7 +54861,7 @@ var init_embedding_runtime = __esm(async () => {
54919
54861
 
54920
54862
  // src/lib/logs-opencode.ts
54921
54863
  import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync9 } from "node:fs";
54922
- import { dirname as dirname26, join as join39 } from "node:path";
54864
+ import { dirname as dirname26, join as join38 } from "node:path";
54923
54865
  function formatTimestamp(date) {
54924
54866
  const pad = (value) => String(value).padStart(2, "0");
54925
54867
  return [
@@ -55008,11 +54950,11 @@ async function bundleIssueReport(report, description, title, sessionFilter = nul
55008
54950
  const bodyMarkdown = capBodyToGithubLimit(rawBodyMarkdown);
55009
54951
  const truncated = bodyMarkdown !== rawBodyMarkdown;
55010
54952
  const timestamp = formatTimestamp(new Date);
55011
- const path = options.outputPath ?? join39(process.cwd(), `magic-context-issue-${timestamp}.md`);
54953
+ const path = options.outputPath ?? join38(process.cwd(), `magic-context-issue-${timestamp}.md`);
55012
54954
  mkdirSync9(dirname26(path), { recursive: true });
55013
54955
  writeFileSync9(path, `${bodyMarkdown}
55014
54956
  `);
55015
- const fullPath = truncated ? options.outputPath ? `${options.outputPath}.full.md` : join39(process.cwd(), `magic-context-issue-${timestamp}-full.md`) : undefined;
54957
+ const fullPath = truncated ? options.outputPath ? `${options.outputPath}.full.md` : join38(process.cwd(), `magic-context-issue-${timestamp}-full.md`) : undefined;
55016
54958
  if (fullPath)
55017
54959
  writeFileSync9(fullPath, `${rawBodyMarkdown}
55018
54960
  `);
@@ -55833,10 +55775,10 @@ function removeDeprecatedReasoningAge(config) {
55833
55775
 
55834
55776
  // src/commands/doctor-opencode.ts
55835
55777
  import { spawnSync as spawnSync10 } from "node:child_process";
55836
- import { existsSync as existsSync49, mkdtempSync as mkdtempSync4, readFileSync as readFileSync32, rmSync as rmSync9 } from "node:fs";
55778
+ import { existsSync as existsSync48, mkdtempSync as mkdtempSync4, readFileSync as readFileSync31, rmSync as rmSync9 } from "node:fs";
55837
55779
  import { createRequire as createRequire6 } from "node:module";
55838
55780
  import { homedir as homedir21, tmpdir as tmpdir4 } from "node:os";
55839
- import { dirname as dirname27, join as join40, resolve as resolve19 } from "node:path";
55781
+ import { dirname as dirname27, join as join39, resolve as resolve19 } from "node:path";
55840
55782
  function formatSharedDbRowCounts(db) {
55841
55783
  return SHARED_DB_ROW_COUNT_TABLES.map((table) => {
55842
55784
  try {
@@ -55907,7 +55849,7 @@ function checkConfiguredVariantCatalog(config, hostGeneration, warn, run = (args
55907
55849
  }
55908
55850
  if (models.length === 0)
55909
55851
  return;
55910
- const tempRoot = mkdtempSync4(join40(tmpdir4(), "magic-context-opencode-catalog-"));
55852
+ const tempRoot = mkdtempSync4(join39(tmpdir4(), "magic-context-opencode-catalog-"));
55911
55853
  try {
55912
55854
  const command = hostGeneration === "v2" ? ["api", "model.list", "--param", `directory=${projectDir}`] : ["models", "--verbose"];
55913
55855
  const guidance = `opencode ${command.join(" ")}`;
@@ -56083,7 +56025,7 @@ function getSelfVersion2() {
56083
56025
  function describeAutoUpdateStall(specifier, autoUpdateEnabled, storageDir = getMagicContextStorageDir()) {
56084
56026
  if (!autoUpdateEnabled || !isPinnedOpenCodePluginSpecifier(specifier))
56085
56027
  return null;
56086
- const state = readAutoUpdateCheckState(join40(storageDir, AUTO_UPDATE_CHECK_STATE_FILENAME));
56028
+ const state = readAutoUpdateCheckState(join39(storageDir, AUTO_UPDATE_CHECK_STATE_FILENAME));
56087
56029
  const owner = isUpdaterPinnedSpec(state, specifier) ? "updater" : "you";
56088
56030
  return `auto-update: stalled — config pinned to ${specifier} (by ${owner})`;
56089
56031
  }
@@ -56092,15 +56034,15 @@ function getUserNpmrcPath() {
56092
56034
  if (custom)
56093
56035
  return custom;
56094
56036
  const home = process.env.HOME?.trim();
56095
- return join40(home || homedir21(), ".npmrc");
56037
+ return join39(home || homedir21(), ".npmrc");
56096
56038
  }
56097
56039
  function collectNpmReleaseAgeWarnings() {
56098
56040
  const ageWarnings = [];
56099
56041
  const npmrcPath = getUserNpmrcPath();
56100
- if (!existsSync49(npmrcPath))
56042
+ if (!existsSync48(npmrcPath))
56101
56043
  return ageWarnings;
56102
56044
  try {
56103
- const npmrc = readFileSync32(npmrcPath, "utf-8");
56045
+ const npmrc = readFileSync31(npmrcPath, "utf-8");
56104
56046
  for (const line of npmrc.split(`
56105
56047
  `)) {
56106
56048
  const trimmed = line.trim();
@@ -56235,7 +56177,7 @@ function checkLocalEmbeddingRuntimeForDoctor(installRoots, runtimePreference = "
56235
56177
  return { issues: 0 };
56236
56178
  }
56237
56179
  async function checkEmbeddingConfig(magicContextConfigPath, installRoots) {
56238
- if (!existsSync49(magicContextConfigPath)) {
56180
+ if (!existsSync48(magicContextConfigPath)) {
56239
56181
  return checkLocalEmbeddingRuntimeForDoctor(installRoots);
56240
56182
  }
56241
56183
  let rawText;
@@ -56410,7 +56352,7 @@ async function runDoctor2(options = {}) {
56410
56352
  const v22Result = await runV22BackfillCommands({
56411
56353
  name: "OpenCode",
56412
56354
  openDatabase: (readonly = true) => {
56413
- const dbPath = join40(getMagicContextStorageDir(), "context.db");
56355
+ const dbPath = join39(getMagicContextStorageDir(), "context.db");
56414
56356
  v22Db = readonly ? openExistingContextDatabase(dbPath, { readonly: true }) : openExistingContextDatabaseForMutation(dbPath);
56415
56357
  return v22Db;
56416
56358
  },
@@ -56446,7 +56388,7 @@ async function runDoctor2(options = {}) {
56446
56388
  if (isMagicContextStorageOutsideEngram(storageDir)) {
56447
56389
  warn(`Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
56448
56390
  }
56449
- const authorityDbPath = join40(getMagicContextStorageDir(), "context.db");
56391
+ const authorityDbPath = join39(getMagicContextStorageDir(), "context.db");
56450
56392
  let authorityDb = null;
56451
56393
  try {
56452
56394
  authorityDb = openExistingContextDatabase(authorityDbPath, { readonly: true });
@@ -56485,7 +56427,7 @@ async function runDoctor2(options = {}) {
56485
56427
  let magicContextStatusKnown = paths.opencodeConfigFormat === "none";
56486
56428
  if (!magicContextStatusKnown) {
56487
56429
  try {
56488
- const config = import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8"));
56430
+ const config = import_comment_json11.parse(readFileSync31(paths.opencodeConfig, "utf-8"));
56489
56431
  magicContextInstalled = isOpenCodePluginRegistered(config, dirname27(paths.opencodeConfig));
56490
56432
  magicContextStatusKnown = true;
56491
56433
  } catch {}
@@ -56621,7 +56563,7 @@ async function runDoctor2(options = {}) {
56621
56563
  pass(`OpenCode config: ${paths.opencodeConfig}`);
56622
56564
  }
56623
56565
  let autoUpdateEnabled = true;
56624
- if (existsSync49(paths.magicContextConfig)) {
56566
+ if (existsSync48(paths.magicContextConfig)) {
56625
56567
  pass(`Magic Context config: ${paths.magicContextConfig}`);
56626
56568
  try {
56627
56569
  const raw = loadRawConfigFile({ configPath: paths.magicContextConfig, tier: "user" });
@@ -56659,7 +56601,7 @@ async function runDoctor2(options = {}) {
56659
56601
  log3.info(rerankConfigSummary());
56660
56602
  log3.info(" Run 'setup' to create one with model recommendations");
56661
56603
  }
56662
- if (existsSync49(paths.magicContextConfig)) {
56604
+ if (existsSync48(paths.magicContextConfig)) {
56663
56605
  try {
56664
56606
  const raw = loadRawConfigFile({ configPath: paths.magicContextConfig, tier: "user" });
56665
56607
  if (!raw)
@@ -56799,7 +56741,7 @@ async function runDoctor2(options = {}) {
56799
56741
  };
56800
56742
  if (paths.opencodeConfigFormat !== "none") {
56801
56743
  try {
56802
- const raw = readFileSync32(paths.opencodeConfig, "utf-8");
56744
+ const raw = readFileSync31(paths.opencodeConfig, "utf-8");
56803
56745
  const config = import_comment_json11.parse(raw);
56804
56746
  const configName = paths.opencodeConfigFormat === "jsonc" ? "opencode.jsonc" : "opencode.json";
56805
56747
  const configDir = dirname27(paths.opencodeConfig);
@@ -56892,9 +56834,9 @@ async function runDoctor2(options = {}) {
56892
56834
  pass("Added TUI sidebar plugin to tui.json");
56893
56835
  warn("Restart OpenCode to see the sidebar");
56894
56836
  fixed++;
56895
- } else if (existsSync49(paths.tuiConfig)) {
56837
+ } else if (existsSync48(paths.tuiConfig)) {
56896
56838
  try {
56897
- const tuiRaw = readFileSync32(paths.tuiConfig, "utf-8");
56839
+ const tuiRaw = readFileSync31(paths.tuiConfig, "utf-8");
56898
56840
  const tuiConfig = import_comment_json11.parse(tuiRaw);
56899
56841
  const tuiConfigDir = dirname27(paths.tuiConfig);
56900
56842
  const tuiRawPlugins = Array.isArray(tuiConfig?.plugin) ? tuiConfig.plugin : [];
@@ -56933,7 +56875,7 @@ async function runDoctor2(options = {}) {
56933
56875
  fail("Could not create or verify the TUI sidebar config");
56934
56876
  }
56935
56877
  }
56936
- if (existsSync49(paths.magicContextConfig)) {
56878
+ if (existsSync48(paths.magicContextConfig)) {
56937
56879
  try {
56938
56880
  const raw = loadRawConfigFile({ configPath: paths.magicContextConfig, tier: "user" });
56939
56881
  if (!raw)
@@ -56949,10 +56891,10 @@ async function runDoctor2(options = {}) {
56949
56891
  let embeddingHostConfig = null;
56950
56892
  try {
56951
56893
  if (paths.opencodeConfigFormat !== "none")
56952
- embeddingHostConfig = import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8"));
56894
+ embeddingHostConfig = import_comment_json11.parse(readFileSync31(paths.opencodeConfig, "utf-8"));
56953
56895
  } catch {}
56954
56896
  const embeddingInstalls = getOpenCodeLoadedPluginInstallRoots(hostGeneration, embeddingHostConfig);
56955
- const unusedInstalls = embeddingInstalls.others.filter((root) => existsSync49(root));
56897
+ const unusedInstalls = embeddingInstalls.others.filter((root) => existsSync48(root));
56956
56898
  if (unusedInstalls.length > 0)
56957
56899
  log3.info(`Local embedding runtime: checked only the copy ${hostGeneration === "v2" ? "OpenCode 2" : "OpenCode 1"} loads; other installed copies (not loaded, not checked): ${unusedInstalls.join(", ")}`);
56958
56900
  const embeddingCheck = await checkEmbeddingConfig(paths.magicContextConfig, embeddingInstalls.loaded);
@@ -56964,9 +56906,9 @@ async function runDoctor2(options = {}) {
56964
56906
  else
56965
56907
  passCount++;
56966
56908
  const storage = getMagicContextStorageResolution();
56967
- const dbPath = join40(storage.path, "context.db");
56909
+ const dbPath = join39(storage.path, "context.db");
56968
56910
  log3.info(`Shared storage: ${storage.path} (source: ${storage.source})`);
56969
- if (!existsSync49(dbPath)) {
56911
+ if (!existsSync48(dbPath)) {
56970
56912
  log3.info(`Shared context DB not yet created at ${dbPath} (will be created on first run)`);
56971
56913
  } else {
56972
56914
  log3.info(`Shared context DB exists at ${dbPath}`);
@@ -57049,7 +56991,7 @@ ${formatDatabaseRepairGuidance(dbPath)}`);
57049
56991
  let pluginConfigUse;
57050
56992
  if (paths.opencodeConfigFormat !== "none") {
57051
56993
  try {
57052
- pluginConfigUse = readOpenCodePluginConfigUse(import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8")), dirname27(paths.opencodeConfig));
56994
+ pluginConfigUse = readOpenCodePluginConfigUse(import_comment_json11.parse(readFileSync31(paths.opencodeConfig, "utf-8")), dirname27(paths.opencodeConfig));
57053
56995
  } catch {}
57054
56996
  }
57055
56997
  const cacheResult = await clearPluginCache({
@@ -57101,7 +57043,7 @@ ${formatDatabaseRepairGuidance(dbPath)}`);
57101
57043
  let v2DistTag;
57102
57044
  if (paths.opencodeConfigFormat !== "none") {
57103
57045
  try {
57104
- v2DistTag = configuredOpenCodeV2DistTag(import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8")));
57046
+ v2DistTag = configuredOpenCodeV2DistTag(import_comment_json11.parse(readFileSync31(paths.opencodeConfig, "utf-8")));
57105
57047
  } catch {}
57106
57048
  }
57107
57049
  const v2Cache = reportOpenCodeV2PluginCache(checkOpenCodeV2PluginCache({
@@ -57503,9 +57445,9 @@ var init_model_chain_health = __esm(() => {
57503
57445
  });
57504
57446
 
57505
57447
  // src/lib/diagnostics-pi.ts
57506
- import { existsSync as existsSync50, readdirSync as readdirSync11, readFileSync as readFileSync33, statSync as statSync26 } from "node:fs";
57448
+ import { existsSync as existsSync49, readdirSync as readdirSync11, readFileSync as readFileSync32, statSync as statSync26 } from "node:fs";
57507
57449
  import { createRequire as createRequire7 } from "node:module";
57508
- import { join as join41 } from "node:path";
57450
+ import { join as join40 } from "node:path";
57509
57451
  function getSelfVersion3() {
57510
57452
  const req = createRequire7(import.meta.url);
57511
57453
  for (const relPath of ["../../package.json", "../package.json"]) {
@@ -57520,7 +57462,7 @@ function getSelfVersion3() {
57520
57462
  }
57521
57463
  function fileSize2(path) {
57522
57464
  try {
57523
- return existsSync50(path) ? statSync26(path).size : 0;
57465
+ return existsSync49(path) ? statSync26(path).size : 0;
57524
57466
  } catch {
57525
57467
  return 0;
57526
57468
  }
@@ -57532,11 +57474,11 @@ function sanitizeValue2(value) {
57532
57474
  return sanitizeConfigValue(value);
57533
57475
  }
57534
57476
  function readJsonc(path) {
57535
- if (!existsSync50(path))
57477
+ if (!existsSync49(path))
57536
57478
  return { value: {} };
57537
57479
  try {
57538
57480
  return {
57539
- value: import_comment_json12.parse(readFileSync33(path, "utf-8"))
57481
+ value: import_comment_json12.parse(readFileSync32(path, "utf-8"))
57540
57482
  };
57541
57483
  } catch (error) {
57542
57484
  return {
@@ -57552,7 +57494,7 @@ function readConfigDiagnostic(path) {
57552
57494
  const parsed = readJsonc(path);
57553
57495
  return {
57554
57496
  path,
57555
- exists: existsSync50(path),
57497
+ exists: existsSync49(path),
57556
57498
  ...parsed.parseError ? { parseError: parsed.parseError } : {},
57557
57499
  flags: sanitizeValue2(parsed.value)
57558
57500
  };
@@ -57570,7 +57512,7 @@ function reverseSlugToDirectory(slug) {
57570
57512
  }
57571
57513
  function collectPiRecentSessions() {
57572
57514
  const sessionsRoot = getPiSessionsRoot();
57573
- if (!existsSync50(sessionsRoot))
57515
+ if (!existsSync49(sessionsRoot))
57574
57516
  return [];
57575
57517
  try {
57576
57518
  const slugs = readdirSync11(sessionsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
@@ -57579,7 +57521,7 @@ function collectPiRecentSessions() {
57579
57521
  const directory = reverseSlugToDirectory(slug);
57580
57522
  if (!directory)
57581
57523
  continue;
57582
- const slugDir = join41(sessionsRoot, slug);
57524
+ const slugDir = join40(sessionsRoot, slug);
57583
57525
  let files;
57584
57526
  try {
57585
57527
  files = readdirSync11(slugDir).filter((name) => name.endsWith(".jsonl"));
@@ -57588,7 +57530,7 @@ function collectPiRecentSessions() {
57588
57530
  }
57589
57531
  for (const file of files) {
57590
57532
  try {
57591
- const mtime = statSync26(join41(slugDir, file)).mtimeMs;
57533
+ const mtime = statSync26(join40(slugDir, file)).mtimeMs;
57592
57534
  const sessionId = file.replace(/\.jsonl$/, "");
57593
57535
  candidates.push({ sessionId, directory, mtime });
57594
57536
  } catch {}
@@ -57606,7 +57548,7 @@ function collectPiRecentSessions() {
57606
57548
  }
57607
57549
  function parseHistorianDumpMeta2(path) {
57608
57550
  try {
57609
- const xml = readFileSync33(path, "utf-8");
57551
+ const xml = readFileSync32(path, "utf-8");
57610
57552
  const parsed = parseCompartmentOutput(xml);
57611
57553
  const factCountByCategory = {};
57612
57554
  for (const fact of parsed.facts) {
@@ -57639,11 +57581,11 @@ function parseHistorianDumpMeta2(path) {
57639
57581
  }
57640
57582
  }
57641
57583
  function listDumpsInDir2(dir, limit) {
57642
- if (!existsSync50(dir))
57584
+ if (!existsSync49(dir))
57643
57585
  return { count: 0, recent: [] };
57644
57586
  try {
57645
57587
  const entries = readdirSync11(dir).filter((name) => name.endsWith(".xml")).map((name) => {
57646
- const stat = statSync26(join41(dir, name));
57588
+ const stat = statSync26(join40(dir, name));
57647
57589
  return {
57648
57590
  name,
57649
57591
  mtime: stat.mtimeMs,
@@ -57652,7 +57594,7 @@ function listDumpsInDir2(dir, limit) {
57652
57594
  }).sort((a, b) => b.mtime - a.mtime);
57653
57595
  const now = Date.now();
57654
57596
  const recent = entries.slice(0, limit).map((entry) => {
57655
- const meta = parseHistorianDumpMeta2(join41(dir, entry.name));
57597
+ const meta = parseHistorianDumpMeta2(join40(dir, entry.name));
57656
57598
  const summary = {
57657
57599
  name: entry.name,
57658
57600
  ageMinutes: Math.round((now - entry.mtime) / 60000),
@@ -57716,7 +57658,7 @@ async function collectDiagnostics2(cwd = process.cwd()) {
57716
57658
  const loaded = loadPiConfig({ cwd });
57717
57659
  const storageResolution = getMagicContextStorageResolution();
57718
57660
  const storageDirPath = storageResolution.path;
57719
- const dbPath = join41(storageDirPath, "context.db");
57661
+ const dbPath = join40(storageDirPath, "context.db");
57720
57662
  const logFiles = inspectMagicContextLogs("pi");
57721
57663
  const primaryLog = logFiles.find((file) => file.exists) ?? logFiles[0];
57722
57664
  const otherPiExtensions = packages.filter((entry) => !isPiMagicContextPackageEntry(entry)).map(describePiPackageEntry);
@@ -57733,7 +57675,7 @@ async function collectDiagnostics2(cwd = process.cwd()) {
57733
57675
  piVersion: pi ? getPiVersion(pi.path) : null,
57734
57676
  settings: {
57735
57677
  path: settingsPath,
57736
- exists: existsSync50(settingsPath),
57678
+ exists: existsSync49(settingsPath),
57737
57679
  ...settingsParsed.parseError ? { parseError: settingsParsed.parseError } : {},
57738
57680
  hasMagicContextPackage: hasPiMagicContextPackage(packages),
57739
57681
  packages: sanitizeValue2(packages)
@@ -57750,7 +57692,7 @@ async function collectDiagnostics2(cwd = process.cwd()) {
57750
57692
  storageDir: {
57751
57693
  path: storageDirPath,
57752
57694
  source: storageResolution.source,
57753
- exists: existsSync50(storageDirPath),
57695
+ exists: existsSync49(storageDirPath),
57754
57696
  contextDbSizeBytes: fileSize2(dbPath)
57755
57697
  },
57756
57698
  conflicts: {
@@ -57858,7 +57800,7 @@ var init_diagnostics_pi = __esm(() => {
57858
57800
 
57859
57801
  // src/lib/logs-pi.ts
57860
57802
  import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync10 } from "node:fs";
57861
- import { dirname as dirname28, join as join42 } from "node:path";
57803
+ import { dirname as dirname28, join as join41 } from "node:path";
57862
57804
  function formatTimestamp2(date) {
57863
57805
  const pad = (value) => String(value).padStart(2, "0");
57864
57806
  return [
@@ -57912,11 +57854,11 @@ async function bundleIssueReport2(report, description, title, options = {}) {
57912
57854
  const truncated = bodyMarkdown !== rawBodyMarkdown;
57913
57855
  const cwd = options.cwd ?? process.cwd();
57914
57856
  const timestamp = formatTimestamp2(options.now ?? new Date);
57915
- const path = options.outputPath ?? join42(cwd, `magic-context-pi-issue-${timestamp}.md`);
57857
+ const path = options.outputPath ?? join41(cwd, `magic-context-pi-issue-${timestamp}.md`);
57916
57858
  mkdirSync10(dirname28(path), { recursive: true });
57917
57859
  writeFileSync10(path, `${bodyMarkdown}
57918
57860
  `);
57919
- const fullPath = truncated ? options.outputPath ? `${options.outputPath}.full.md` : join42(cwd, `magic-context-pi-issue-${timestamp}-full.md`) : undefined;
57861
+ const fullPath = truncated ? options.outputPath ? `${options.outputPath}.full.md` : join41(cwd, `magic-context-pi-issue-${timestamp}-full.md`) : undefined;
57920
57862
  if (fullPath)
57921
57863
  writeFileSync10(fullPath, `${rawBodyMarkdown}
57922
57864
  `);
@@ -57930,10 +57872,10 @@ var init_logs_pi = __esm(() => {
57930
57872
 
57931
57873
  // src/commands/doctor-pi.ts
57932
57874
  import { execFileSync as execFileSync9, spawnSync as spawnSync11 } from "node:child_process";
57933
- import { existsSync as existsSync51, readdirSync as readdirSync12, readFileSync as readFileSync34, rmSync as rmSync10, statSync as statSync27 } from "node:fs";
57875
+ import { existsSync as existsSync50, readdirSync as readdirSync12, readFileSync as readFileSync33, rmSync as rmSync10, statSync as statSync27 } from "node:fs";
57934
57876
  import { createRequire as createRequire8 } from "node:module";
57935
57877
  import { homedir as homedir22 } from "node:os";
57936
- import { isAbsolute as isAbsolute9, join as join43 } from "node:path";
57878
+ import { isAbsolute as isAbsolute9, join as join42 } from "node:path";
57937
57879
  function depsFrom(options) {
57938
57880
  return {
57939
57881
  ...DEFAULT_DEPS5,
@@ -58025,7 +57967,7 @@ function summarize(results) {
58025
57967
  function readJsonc2(path) {
58026
57968
  try {
58027
57969
  return {
58028
- value: import_comment_json13.parse(readFileSync34(path, "utf-8"))
57970
+ value: import_comment_json13.parse(readFileSync33(path, "utf-8"))
58029
57971
  };
58030
57972
  } catch (error) {
58031
57973
  return {
@@ -58075,15 +58017,15 @@ function piPluginDirCandidates(packages, cwd) {
58075
58017
  if (resolved)
58076
58018
  dirs.push(resolved);
58077
58019
  }
58078
- dirs.push(join43(agentDir, "npm", "node_modules", PACKAGE_NAME2));
58079
- dirs.push(join43(cwd, ".pi", "npm", "node_modules", PACKAGE_NAME2));
58080
- return dirs.filter((dir) => existsSync51(join43(dir, "package.json")));
58020
+ dirs.push(join42(agentDir, "npm", "node_modules", PACKAGE_NAME2));
58021
+ dirs.push(join42(cwd, ".pi", "npm", "node_modules", PACKAGE_NAME2));
58022
+ return dirs.filter((dir) => existsSync50(join42(dir, "package.json")));
58081
58023
  }
58082
58024
  function projectConfigPath(cwd) {
58083
58025
  return resolveCortexKitProjectConfigPath(cwd);
58084
58026
  }
58085
58027
  function readConfigForEmbedding(path, isProjectConfig) {
58086
- if (!existsSync51(path))
58028
+ if (!existsSync50(path))
58087
58029
  return null;
58088
58030
  try {
58089
58031
  const raw = loadRawConfigFile({
@@ -58169,22 +58111,22 @@ function pinnedVersionFromPackageSpecifier(specifier) {
58169
58111
  }
58170
58112
  function cacheRoots(cwd) {
58171
58113
  const home = process.env.HOME?.trim();
58172
- const cacheHome = process.env.XDG_CACHE_HOME || join43(home || homedir22(), ".cache");
58114
+ const cacheHome = process.env.XDG_CACHE_HOME || join42(home || homedir22(), ".cache");
58173
58115
  const piCacheRoot = getPiCacheRoot();
58174
58116
  return [
58175
- join43(piCacheRoot, "extensions"),
58176
- join43(piCacheRoot, "packages"),
58177
- join43(cacheHome, "pi", "extensions"),
58178
- join43(cacheHome, "pi", "packages"),
58179
- join43(getPiAgentConfigDir(), "cache", "extensions"),
58180
- join43(getPiAgentConfigDir(), "npm", "node_modules", PACKAGE_NAME2),
58181
- join43(cwd, ".pi", "npm", "node_modules", PACKAGE_NAME2)
58117
+ join42(piCacheRoot, "extensions"),
58118
+ join42(piCacheRoot, "packages"),
58119
+ join42(cacheHome, "pi", "extensions"),
58120
+ join42(cacheHome, "pi", "packages"),
58121
+ join42(getPiAgentConfigDir(), "cache", "extensions"),
58122
+ join42(getPiAgentConfigDir(), "npm", "node_modules", PACKAGE_NAME2),
58123
+ join42(cwd, ".pi", "npm", "node_modules", PACKAGE_NAME2)
58182
58124
  ];
58183
58125
  }
58184
58126
  function findPiMagicContextCacheDirs(cwd, expectedVersion, force = false) {
58185
58127
  const found = new Map;
58186
58128
  const visit = (path, depth) => {
58187
- if (depth < 0 || !existsSync51(path))
58129
+ if (depth < 0 || !existsSync50(path))
58188
58130
  return;
58189
58131
  let stat;
58190
58132
  try {
@@ -58194,10 +58136,10 @@ function findPiMagicContextCacheDirs(cwd, expectedVersion, force = false) {
58194
58136
  }
58195
58137
  if (!stat.isDirectory())
58196
58138
  return;
58197
- const packageJson = join43(path, "package.json");
58198
- if (existsSync51(packageJson)) {
58139
+ const packageJson = join42(path, "package.json");
58140
+ if (existsSync50(packageJson)) {
58199
58141
  try {
58200
- const pkg = JSON.parse(readFileSync34(packageJson, "utf-8"));
58142
+ const pkg = JSON.parse(readFileSync33(packageJson, "utf-8"));
58201
58143
  const name = typeof pkg.name === "string" ? pkg.name : "";
58202
58144
  const version = typeof pkg.version === "string" ? pkg.version : undefined;
58203
58145
  if (name === PACKAGE_NAME2) {
@@ -58217,7 +58159,7 @@ function findPiMagicContextCacheDirs(cwd, expectedVersion, force = false) {
58217
58159
  return;
58218
58160
  }
58219
58161
  for (const entry of entries)
58220
- visit(join43(path, entry), depth - 1);
58162
+ visit(join42(path, entry), depth - 1);
58221
58163
  };
58222
58164
  for (const root of cacheRoots(cwd))
58223
58165
  visit(root, 5);
@@ -58278,7 +58220,7 @@ async function runHealthChecks2(options) {
58278
58220
  const settingsPath = getPiUserExtensionsPath();
58279
58221
  let packages = [];
58280
58222
  let piPluginInstalled = false;
58281
- if (!existsSync51(settingsPath)) {
58223
+ if (!existsSync50(settingsPath)) {
58282
58224
  if (pi) {
58283
58225
  add2(results, "info", `${piVersion ? `Pi ${piVersion}` : "Pi"} found; Magic Context is not installed there (run setup to add it)`);
58284
58226
  }
@@ -58320,7 +58262,7 @@ async function runHealthChecks2(options) {
58320
58262
  ["user", userConfigPath, true],
58321
58263
  ["project", projectPath, false]
58322
58264
  ]) {
58323
- if (!existsSync51(path)) {
58265
+ if (!existsSync50(path)) {
58324
58266
  if (required) {
58325
58267
  add2(results, "warn", `No ${label} magic-context.jsonc found at ${path}`);
58326
58268
  if (userConfigMigrationRefused) {
@@ -58367,12 +58309,12 @@ async function runHealthChecks2(options) {
58367
58309
  checkPiModelChains(results, pi, loadedConfig.config, options.deps);
58368
58310
  const storage = getMagicContextStorageResolution();
58369
58311
  const storageDir = storage.path;
58370
- const dbPath = join43(storageDir, "context.db");
58312
+ const dbPath = join42(storageDir, "context.db");
58371
58313
  if (isMagicContextStorageOutsideEngram(storageDir)) {
58372
58314
  add2(results, "warn", `Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
58373
58315
  }
58374
58316
  add2(results, "info", `Shared storage: ${storageDir} (source: ${storage.source})`);
58375
- const existedBeforeOpen = existsSync51(dbPath);
58317
+ const existedBeforeOpen = existsSync50(dbPath);
58376
58318
  if (existedBeforeOpen)
58377
58319
  add2(results, "pass", `Shared context DB exists at ${dbPath}`);
58378
58320
  else
@@ -58601,7 +58543,7 @@ function writeDefaultMagicContextConfig(path) {
58601
58543
  function repair2(plan, prompts) {
58602
58544
  let fixed = 0;
58603
58545
  for (const path of plan.reasoningAgeConfigPaths) {
58604
- const content = readFileSync34(path, "utf8");
58546
+ const content = readFileSync33(path, "utf8");
58605
58547
  const parsed = readJsonc2(path);
58606
58548
  if (parsed.error)
58607
58549
  continue;
@@ -58627,7 +58569,7 @@ function repair2(plan, prompts) {
58627
58569
  }
58628
58570
  if (plan.writeUserConfig) {
58629
58571
  const configPath = getPiUserConfigPath();
58630
- if (!existsSync51(configPath)) {
58572
+ if (!existsSync50(configPath)) {
58631
58573
  try {
58632
58574
  writeDefaultMagicContextConfig(configPath);
58633
58575
  prompts.log.success(`Wrote default Magic Context config to ${configPath}`);
@@ -58681,7 +58623,7 @@ async function runIssueFlow3(options) {
58681
58623
  if (options.reportPath) {
58682
58624
  try {
58683
58625
  const report = await options.deps.collectDiagnostics(options.cwd);
58684
- const outputPath = isAbsolute9(options.reportPath) ? options.reportPath : join43(options.cwd, options.reportPath);
58626
+ const outputPath = isAbsolute9(options.reportPath) ? options.reportPath : join42(options.cwd, options.reportPath);
58685
58627
  const bundled = await bundleIssueReport2(report, "Generated non-interactively by `doctor --issue --report`.", "Magic Context diagnostic report", { cwd: options.cwd, now: options.deps.now(), outputPath });
58686
58628
  options.prompts.log.info(`Report written to ${bundled.path}`);
58687
58629
  return 0;
@@ -58765,7 +58707,7 @@ async function runDoctor3(options = {}) {
58765
58707
  const v22Result = await runV22BackfillCommands({
58766
58708
  name: "Pi",
58767
58709
  openDatabase: (readonly = true) => {
58768
- const dbPath = join43(getMagicContextStorageDir(), "context.db");
58710
+ const dbPath = join42(getMagicContextStorageDir(), "context.db");
58769
58711
  v22Db = readonly ? openExistingContextDatabase(dbPath, { readonly: true }) : openExistingContextDatabaseForMutation(dbPath);
58770
58712
  return v22Db;
58771
58713
  },
@@ -58883,8 +58825,8 @@ var init_doctor_pi = __esm(async () => {
58883
58825
  });
58884
58826
 
58885
58827
  // src/commands/doctor.ts
58886
- import { existsSync as existsSync52, rmSync as rmSync11 } from "node:fs";
58887
- import { join as join44 } from "node:path";
58828
+ import { existsSync as existsSync51, rmSync as rmSync11 } from "node:fs";
58829
+ import { join as join43 } from "node:path";
58888
58830
  async function runDoctor4(options) {
58889
58831
  if (options.clear)
58890
58832
  return runClear();
@@ -58902,7 +58844,7 @@ async function runDoctor4(options) {
58902
58844
  const result = await runV22BackfillCommands({
58903
58845
  name: "Magic Context",
58904
58846
  openDatabase: (readonly = true) => {
58905
- const dbPath = join44(getMagicContextStorageDir(), "context.db");
58847
+ const dbPath = join43(getMagicContextStorageDir(), "context.db");
58906
58848
  v22Db = readonly ? openExistingContextDatabase(dbPath, { readonly: true }) : openExistingContextDatabaseForMutation(dbPath);
58907
58849
  return v22Db;
58908
58850
  },
@@ -58922,7 +58864,7 @@ async function runDoctor4(options) {
58922
58864
  log3.warn(`Identity split check unavailable: ${error instanceof Error ? error.message : String(error)}`);
58923
58865
  }
58924
58866
  await init_migrate();
58925
- const sweepDbPath = join44(getMagicContextStorageDir(), "context.db");
58867
+ const sweepDbPath = join43(getMagicContextStorageDir(), "context.db");
58926
58868
  let sweepDb = null;
58927
58869
  try {
58928
58870
  sweepDb = openExistingContextDatabaseForMutation(sweepDbPath);
@@ -59039,7 +58981,7 @@ async function runClear() {
59039
58981
  failed += 1;
59040
58982
  continue;
59041
58983
  }
59042
- } else if (existsSync52(item.path)) {
58984
+ } else if (existsSync51(item.path)) {
59043
58985
  rmSync11(item.path, { recursive: true, force: true });
59044
58986
  }
59045
58987
  s.stop(`Cleared ${item.path}`);