@cortexkit/magic-context 0.17.2 → 0.18.0

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 +171 -132
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7926,19 +7926,27 @@ function dirSizeBytes(path) {
7926
7926
  var init_paths = () => {};
7927
7927
 
7928
7928
  // src/adapters/opencode.ts
7929
- import { execSync } from "node:child_process";
7929
+ import { execFileSync } from "node:child_process";
7930
7930
  import { existsSync as existsSync2, readFileSync, writeFileSync } from "node:fs";
7931
- import { dirname } from "node:path";
7931
+ import { homedir as homedir2 } from "node:os";
7932
+ import { dirname, join as join2 } from "node:path";
7932
7933
 
7933
7934
  class OpenCodeAdapter {
7934
7935
  kind = "opencode";
7935
7936
  displayName = "OpenCode";
7936
7937
  pluginPackageName = PLUGIN_NAME;
7937
7938
  isInstalled() {
7938
- if (existsSync2(`${process.env.HOME ?? ""}/.opencode/bin/opencode`))
7939
+ const isWindows = process.platform === "win32";
7940
+ const stockBin = isWindows ? join2(homedir2(), ".opencode", "bin", "opencode.exe") : join2(homedir2(), ".opencode", "bin", "opencode");
7941
+ if (existsSync2(stockBin))
7939
7942
  return true;
7943
+ const probe = isWindows ? { cmd: "where", args: ["opencode"] } : { cmd: "command", args: ["-v", "opencode"] };
7940
7944
  try {
7941
- execSync("command -v opencode", { stdio: "ignore" });
7945
+ if (!isWindows) {
7946
+ execFileSync("which", ["opencode"], { stdio: "ignore" });
7947
+ } else {
7948
+ execFileSync(probe.cmd, probe.args, { stdio: "ignore" });
7949
+ }
7942
7950
  return true;
7943
7951
  } catch {
7944
7952
  return false;
@@ -8175,16 +8183,16 @@ var init_opencode = __esm(() => {
8175
8183
  });
8176
8184
 
8177
8185
  // src/lib/pi-helpers.ts
8178
- import { execFileSync, spawnSync } from "node:child_process";
8186
+ import { execFileSync as execFileSync2, spawnSync } from "node:child_process";
8179
8187
  import { existsSync as existsSync3 } from "node:fs";
8180
- import { homedir as homedir2 } from "node:os";
8181
- import { join as join2 } from "node:path";
8188
+ import { homedir as homedir3 } from "node:os";
8189
+ import { join as join3 } from "node:path";
8182
8190
  function getStaticModels() {
8183
8191
  return [...STATIC_MODELS];
8184
8192
  }
8185
8193
  function commandExists(command, args) {
8186
8194
  try {
8187
- const output = execFileSync(command, args, {
8195
+ const output = execFileSync2(command, args, {
8188
8196
  encoding: "utf-8",
8189
8197
  stdio: ["ignore", "pipe", "ignore"]
8190
8198
  }).trim();
@@ -8200,7 +8208,7 @@ function detectPiBinary() {
8200
8208
  if (first)
8201
8209
  return { path: first, source: "path" };
8202
8210
  }
8203
- const homeCandidate = process.platform === "win32" ? join2(homedir2(), ".pi", "bin", "pi.cmd") : join2(homedir2(), ".pi", "bin", "pi");
8211
+ const homeCandidate = process.platform === "win32" ? join3(homedir3(), ".pi", "bin", "pi.cmd") : join3(homedir3(), ".pi", "bin", "pi");
8204
8212
  if (existsSync3(homeCandidate))
8205
8213
  return { path: homeCandidate, source: "home" };
8206
8214
  return null;
@@ -8224,7 +8232,7 @@ function getPiVersion(piPath) {
8224
8232
  }
8225
8233
  function runPi(piPath, args) {
8226
8234
  try {
8227
- return execFileSync(piPath, args, {
8235
+ return execFileSync2(piPath, args, {
8228
8236
  encoding: "utf-8",
8229
8237
  stdio: ["ignore", "pipe", "ignore"],
8230
8238
  timeout: 20000
@@ -8351,7 +8359,7 @@ var init_pi_helpers = __esm(() => {
8351
8359
  });
8352
8360
 
8353
8361
  // src/adapters/pi.ts
8354
- import { execFileSync as execFileSync2 } from "node:child_process";
8362
+ import { execFileSync as execFileSync3 } from "node:child_process";
8355
8363
  import { existsSync as existsSync4, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
8356
8364
  import { dirname as dirname2 } from "node:path";
8357
8365
 
@@ -8462,7 +8470,7 @@ class PiAdapter {
8462
8470
  if (!piBin)
8463
8471
  return null;
8464
8472
  try {
8465
- const output = execFileSync2(piBin.path, ["list"], {
8473
+ const output = execFileSync3(piBin.path, ["list"], {
8466
8474
  encoding: "utf-8",
8467
8475
  stdio: ["ignore", "pipe", "ignore"],
8468
8476
  timeout: 5000
@@ -10319,17 +10327,17 @@ function detectConfigFile(basePath) {
10319
10327
  var init_jsonc_parser = () => {};
10320
10328
 
10321
10329
  // ../plugin/src/shared/opencode-config-dir.ts
10322
- import { homedir as homedir3 } from "node:os";
10323
- import { join as join3, resolve } from "node:path";
10330
+ import { homedir as homedir4 } from "node:os";
10331
+ import { join as join4, resolve } from "node:path";
10324
10332
  function getCliConfigDir() {
10325
10333
  const envConfigDir = process.env.OPENCODE_CONFIG_DIR?.trim();
10326
10334
  if (envConfigDir) {
10327
10335
  return resolve(envConfigDir);
10328
10336
  }
10329
10337
  if (process.platform === "win32") {
10330
- return join3(homedir3(), ".config", "opencode");
10338
+ return join4(homedir4(), ".config", "opencode");
10331
10339
  }
10332
- return join3(process.env.XDG_CONFIG_HOME || join3(homedir3(), ".config"), "opencode");
10340
+ return join4(process.env.XDG_CONFIG_HOME || join4(homedir4(), ".config"), "opencode");
10333
10341
  }
10334
10342
  function getOpenCodeConfigDir2(_options) {
10335
10343
  return getCliConfigDir();
@@ -10338,16 +10346,16 @@ function getOpenCodeConfigPaths(options) {
10338
10346
  const configDir = getOpenCodeConfigDir2(options);
10339
10347
  return {
10340
10348
  configDir,
10341
- configJson: join3(configDir, "opencode.json"),
10342
- configJsonc: join3(configDir, "opencode.jsonc"),
10343
- packageJson: join3(configDir, "package.json"),
10344
- omoConfig: join3(configDir, "magic-context.jsonc")
10349
+ configJson: join4(configDir, "opencode.json"),
10350
+ configJsonc: join4(configDir, "opencode.jsonc"),
10351
+ packageJson: join4(configDir, "package.json"),
10352
+ omoConfig: join4(configDir, "magic-context.jsonc")
10345
10353
  };
10346
10354
  }
10347
10355
  var init_opencode_config_dir = () => {};
10348
10356
 
10349
10357
  // ../plugin/src/shared/conflict-detector.ts
10350
- import { join as join4 } from "node:path";
10358
+ import { join as join5 } from "node:path";
10351
10359
  function detectConflicts(directory) {
10352
10360
  const conflicts = {
10353
10361
  compactionAuto: false,
@@ -10404,8 +10412,8 @@ function checkCompaction(directory) {
10404
10412
  return { auto: true, prune: false };
10405
10413
  }
10406
10414
  function readProjectCompaction(directory) {
10407
- const dotOcJsonc = join4(directory, ".opencode", "opencode.jsonc");
10408
- const dotOcJson = join4(directory, ".opencode", "opencode.json");
10415
+ const dotOcJsonc = join5(directory, ".opencode", "opencode.jsonc");
10416
+ const dotOcJson = join5(directory, ".opencode", "opencode.json");
10409
10417
  const dotOcConfig = readJsoncFile(dotOcJsonc) ?? readJsoncFile(dotOcJson);
10410
10418
  if (dotOcConfig?.compaction) {
10411
10419
  const c2 = dotOcConfig.compaction;
@@ -10413,8 +10421,8 @@ function readProjectCompaction(directory) {
10413
10421
  return { auto: c2.auto === true, prune: c2.prune === true, resolved: true };
10414
10422
  }
10415
10423
  }
10416
- const rootJsonc = join4(directory, "opencode.jsonc");
10417
- const rootJson = join4(directory, "opencode.json");
10424
+ const rootJsonc = join5(directory, "opencode.jsonc");
10425
+ const rootJson = join5(directory, "opencode.json");
10418
10426
  const rootConfig = readJsoncFile(rootJsonc) ?? readJsoncFile(rootJson);
10419
10427
  if (rootConfig?.compaction) {
10420
10428
  const c2 = rootConfig.compaction;
@@ -10468,10 +10476,10 @@ function collectPluginEntries(directory) {
10468
10476
  }
10469
10477
  };
10470
10478
  for (const configPath of [
10471
- join4(directory, ".opencode", "opencode.jsonc"),
10472
- join4(directory, ".opencode", "opencode.json"),
10473
- join4(directory, "opencode.jsonc"),
10474
- join4(directory, "opencode.json")
10479
+ join5(directory, ".opencode", "opencode.jsonc"),
10480
+ join5(directory, ".opencode", "opencode.json"),
10481
+ join5(directory, "opencode.jsonc"),
10482
+ join5(directory, "opencode.json")
10475
10483
  ]) {
10476
10484
  const config = readJsoncFile(configPath);
10477
10485
  pushFrom(config?.plugin);
@@ -10512,7 +10520,7 @@ function readOmoDisabledHooks(directory) {
10512
10520
  try {
10513
10521
  const paths = getOpenCodeConfigPaths({ binary: "opencode" });
10514
10522
  for (const name of configNames) {
10515
- const configPath = join4(paths.configDir, name);
10523
+ const configPath = join5(paths.configDir, name);
10516
10524
  const config = readJsoncFile(configPath);
10517
10525
  if (config?.disabled_hooks) {
10518
10526
  for (const hook of config.disabled_hooks) {
@@ -10522,7 +10530,7 @@ function readOmoDisabledHooks(directory) {
10522
10530
  }
10523
10531
  } catch {}
10524
10532
  for (const name of configNames) {
10525
- const config = readJsoncFile(join4(directory, name));
10533
+ const config = readJsoncFile(join5(directory, name));
10526
10534
  if (config?.disabled_hooks) {
10527
10535
  for (const hook of config.disabled_hooks) {
10528
10536
  disabled.add(hook);
@@ -10541,7 +10549,7 @@ var init_conflict_detector = __esm(() => {
10541
10549
 
10542
10550
  // ../plugin/src/shared/conflict-fixer.ts
10543
10551
  import { existsSync as existsSync6, mkdirSync, writeFileSync as writeFileSync3 } from "node:fs";
10544
- import { dirname as dirname3, join as join5 } from "node:path";
10552
+ import { dirname as dirname3, join as join6 } from "node:path";
10545
10553
  function ensureParentDir(filePath) {
10546
10554
  mkdirSync(dirname3(filePath), { recursive: true });
10547
10555
  }
@@ -10573,10 +10581,10 @@ function collectOpenCodeConfigPaths(directory) {
10573
10581
  const userConfig = resolveUserOpenCodeConfigPath();
10574
10582
  paths.add(userConfig);
10575
10583
  for (const filePath of [
10576
- join5(directory, ".opencode", "opencode.jsonc"),
10577
- join5(directory, ".opencode", "opencode.json"),
10578
- join5(directory, "opencode.jsonc"),
10579
- join5(directory, "opencode.json")
10584
+ join6(directory, ".opencode", "opencode.jsonc"),
10585
+ join6(directory, ".opencode", "opencode.json"),
10586
+ join6(directory, "opencode.jsonc"),
10587
+ join6(directory, "opencode.json")
10580
10588
  ]) {
10581
10589
  if (existsSync6(filePath)) {
10582
10590
  paths.add(filePath);
@@ -10588,8 +10596,8 @@ function collectOmoConfigPaths(directory) {
10588
10596
  const paths = new Set;
10589
10597
  const configDir = getOpenCodeConfigPaths({ binary: "opencode" }).configDir;
10590
10598
  for (const fileName of OMO_CONFIG_NAMES) {
10591
- const userPath = join5(configDir, fileName);
10592
- const projectPath = join5(directory, fileName);
10599
+ const userPath = join6(configDir, fileName);
10600
+ const projectPath = join6(directory, fileName);
10593
10601
  if (existsSync6(userPath)) {
10594
10602
  paths.add(userPath);
10595
10603
  }
@@ -10598,7 +10606,7 @@ function collectOmoConfigPaths(directory) {
10598
10606
  }
10599
10607
  }
10600
10608
  if (paths.size === 0) {
10601
- paths.add(join5(configDir, "oh-my-openagent.json"));
10609
+ paths.add(join6(configDir, "oh-my-openagent.json"));
10602
10610
  }
10603
10611
  return [...paths];
10604
10612
  }
@@ -10705,10 +10713,10 @@ var init_conflict_fixer = __esm(() => {
10705
10713
  });
10706
10714
 
10707
10715
  // src/lib/opencode-helpers.ts
10708
- import { execSync as execSync2 } from "node:child_process";
10716
+ import { execSync } from "node:child_process";
10709
10717
  function isOpenCodeInstalled() {
10710
10718
  try {
10711
- execSync2("opencode --version", { stdio: "pipe" });
10719
+ execSync("opencode --version", { stdio: "pipe" });
10712
10720
  return true;
10713
10721
  } catch {
10714
10722
  return false;
@@ -10716,14 +10724,14 @@ function isOpenCodeInstalled() {
10716
10724
  }
10717
10725
  function getOpenCodeVersion() {
10718
10726
  try {
10719
- return execSync2("opencode --version", { stdio: "pipe" }).toString().trim();
10727
+ return execSync("opencode --version", { stdio: "pipe" }).toString().trim();
10720
10728
  } catch {
10721
10729
  return null;
10722
10730
  }
10723
10731
  }
10724
10732
  function getAvailableModels2() {
10725
10733
  try {
10726
- const output = execSync2("opencode models", { stdio: "pipe" }).toString().trim();
10734
+ const output = execSync("opencode models", { stdio: "pipe" }).toString().trim();
10727
10735
  return output.split(`
10728
10736
  `).map((l) => l.trim()).filter(Boolean);
10729
10737
  } catch {
@@ -11062,8 +11070,8 @@ async function runSetup() {
11062
11070
  const shouldStar = await confirm("★ Star the repo on GitHub?", true);
11063
11071
  if (shouldStar) {
11064
11072
  try {
11065
- const { execSync: execSync3 } = await import("node:child_process");
11066
- execSync3("gh api --silent --method PUT /user/starred/cortexkit/magic-context", {
11073
+ const { execSync: execSync2 } = await import("node:child_process");
11074
+ execSync2("gh api --silent --method PUT /user/starred/cortexkit/magic-context", {
11067
11075
  stdio: "ignore",
11068
11076
  timeout: 1e4
11069
11077
  });
@@ -11799,16 +11807,16 @@ __export(exports_migrate, {
11799
11807
  });
11800
11808
  import { randomBytes } from "node:crypto";
11801
11809
  import { existsSync as existsSync10, mkdirSync as mkdirSync5, writeFileSync as writeFileSync7 } from "node:fs";
11802
- import { homedir as homedir5 } from "node:os";
11803
- import { join as join9 } from "node:path";
11810
+ import { homedir as homedir6 } from "node:os";
11811
+ import { join as join10 } from "node:path";
11804
11812
  function defaultOpenCodeDbPath() {
11805
- return join9(homedir5(), ".local", "share", "opencode", "opencode.db");
11813
+ return join10(homedir6(), ".local", "share", "opencode", "opencode.db");
11806
11814
  }
11807
11815
  function defaultCortexkitDbPath() {
11808
- return join9(getMagicContextStorageDir(), "context.db");
11816
+ return join10(getMagicContextStorageDir(), "context.db");
11809
11817
  }
11810
11818
  function defaultPiSessionsRoot() {
11811
- return join9(homedir5(), ".pi", "agent", "sessions");
11819
+ return join10(homedir6(), ".pi", "agent", "sessions");
11812
11820
  }
11813
11821
  function defaultFs() {
11814
11822
  return { existsSync: existsSync10, mkdirSync: mkdirSync5, writeFileSync: writeFileSync7 };
@@ -12234,7 +12242,7 @@ function migrateOpenCodeSessionToPi(opts) {
12234
12242
  const provider = opts.provider ?? model.provider;
12235
12243
  const modelId = opts.modelId ?? model.modelId;
12236
12244
  const cwd = session.directory ?? session.path ?? process.cwd();
12237
- const outputDir = join9(piSessionsRoot, projectPathToPiDirSlug(cwd));
12245
+ const outputDir = join10(piSessionsRoot, projectPathToPiDirSlug(cwd));
12238
12246
  const buildResult = buildPiEntries({
12239
12247
  session,
12240
12248
  messages,
@@ -12260,7 +12268,7 @@ function migrateOpenCodeSessionToPi(opts) {
12260
12268
  });
12261
12269
  }
12262
12270
  const compactionMarker = insertCompactionMarker(buildResult.entries, copyResult.lastCompartmentEndPiEntryId);
12263
- const outputPath = join9(outputDir, `${formatPiFilenameTimestamp(now)}_${buildResult.piSessionId}.jsonl`);
12271
+ const outputPath = join10(outputDir, `${formatPiFilenameTimestamp(now)}_${buildResult.piSessionId}.jsonl`);
12264
12272
  const jsonl = `${buildResult.entries.map((entry) => JSON.stringify(entry)).join(`
12265
12273
  `)}
12266
12274
  `;
@@ -27229,7 +27237,7 @@ var init_magic_context = __esm(() => {
27229
27237
 
27230
27238
  // ../plugin/src/config/variable.ts
27231
27239
  import { existsSync as existsSync11, readFileSync as readFileSync6 } from "node:fs";
27232
- import { homedir as homedir6 } from "node:os";
27240
+ import { homedir as homedir7 } from "node:os";
27233
27241
  import { dirname as dirname7, isAbsolute, resolve as resolve2 } from "node:path";
27234
27242
  function substituteConfigVariables(input) {
27235
27243
  const warnings = [];
@@ -27265,7 +27273,7 @@ function substituteConfigVariables(input) {
27265
27273
  }
27266
27274
  let filePath = rawPath.trim();
27267
27275
  if (filePath.startsWith("~/")) {
27268
- filePath = resolve2(homedir6(), filePath.slice(2));
27276
+ filePath = resolve2(homedir7(), filePath.slice(2));
27269
27277
  } else if (!isAbsolute(filePath)) {
27270
27278
  filePath = resolve2(configDir, filePath);
27271
27279
  }
@@ -27294,14 +27302,14 @@ var init_variable = __esm(() => {
27294
27302
 
27295
27303
  // ../plugin/src/config/index.ts
27296
27304
  import { existsSync as existsSync12, readFileSync as readFileSync7 } from "node:fs";
27297
- import { homedir as homedir7 } from "node:os";
27298
- import { join as join10 } from "node:path";
27305
+ import { homedir as homedir8 } from "node:os";
27306
+ import { join as join11 } from "node:path";
27299
27307
  function getUserConfigBasePath() {
27300
- const configRoot = process.env.XDG_CONFIG_HOME ?? join10(homedir7(), ".config");
27301
- return join10(configRoot, "opencode", CONFIG_FILE_BASENAME);
27308
+ const configRoot = process.env.XDG_CONFIG_HOME ?? join11(homedir8(), ".config");
27309
+ return join11(configRoot, "opencode", CONFIG_FILE_BASENAME);
27302
27310
  }
27303
27311
  function getProjectConfigBasePath(directory) {
27304
- return join10(directory, ".opencode", CONFIG_FILE_BASENAME);
27312
+ return join11(directory, ".opencode", CONFIG_FILE_BASENAME);
27305
27313
  }
27306
27314
  function loadConfigFile(configPath) {
27307
27315
  try {
@@ -27482,7 +27490,7 @@ function parsePluginConfig(rawConfig) {
27482
27490
  }
27483
27491
  function loadPluginConfig(directory) {
27484
27492
  const userDetected = detectConfigFile(getUserConfigBasePath());
27485
- const rootDetected = detectConfigFile(join10(directory, CONFIG_FILE_BASENAME));
27493
+ const rootDetected = detectConfigFile(join11(directory, CONFIG_FILE_BASENAME));
27486
27494
  const dotOpenCodeDetected = detectConfigFile(getProjectConfigBasePath(directory));
27487
27495
  const projectDetected = rootDetected.format !== "none" ? rootDetected : dotOpenCodeDetected;
27488
27496
  const userLoaded = userDetected.format === "none" ? null : loadConfigFile(userDetected.path);
@@ -27627,7 +27635,7 @@ var DEFAULT_TIMEOUT_MS = 1e4, MAX_PREVIEW_CHARS = 240;
27627
27635
 
27628
27636
  // ../plugin/src/shared/tui-config.ts
27629
27637
  import { existsSync as existsSync13, mkdirSync as mkdirSync6, readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "node:fs";
27630
- import { dirname as dirname8, join as join11 } from "node:path";
27638
+ import { dirname as dirname8, join as join12 } from "node:path";
27631
27639
  function isMagicContextEntry(entry) {
27632
27640
  if (!entry)
27633
27641
  return false;
@@ -27641,8 +27649,8 @@ function isMagicContextEntry(entry) {
27641
27649
  }
27642
27650
  function resolveTuiConfigPath() {
27643
27651
  const configDir = getOpenCodeConfigPaths({ binary: "opencode" }).configDir;
27644
- const jsoncPath = join11(configDir, "tui.jsonc");
27645
- const jsonPath = join11(configDir, "tui.json");
27652
+ const jsoncPath = join12(configDir, "tui.jsonc");
27653
+ const jsonPath = join12(configDir, "tui.json");
27646
27654
  if (existsSync13(jsoncPath))
27647
27655
  return jsoncPath;
27648
27656
  if (existsSync13(jsonPath))
@@ -27744,8 +27752,8 @@ var init_compartment_parser = __esm(() => {
27744
27752
  // src/lib/diagnostics-opencode.ts
27745
27753
  import { existsSync as existsSync14, readdirSync as readdirSync2, readFileSync as readFileSync9, statSync as statSync2 } from "node:fs";
27746
27754
  import { createRequire as createRequire3 } from "node:module";
27747
- import { homedir as homedir8, tmpdir as tmpdir3, userInfo } from "node:os";
27748
- import { join as join12 } from "node:path";
27755
+ import { homedir as homedir9, tmpdir as tmpdir3, userInfo } from "node:os";
27756
+ import { join as join13 } from "node:path";
27749
27757
  function getSelfVersion() {
27750
27758
  const require2 = createRequire3(import.meta.url);
27751
27759
  for (const relPath of ["../../package.json", "../package.json"]) {
@@ -27759,10 +27767,10 @@ function getSelfVersion() {
27759
27767
  return "unknown";
27760
27768
  }
27761
27769
  function getPluginCacheInfo() {
27762
- const path4 = join12(getOpenCodeCacheDir(), "packages", PLUGIN_ENTRY_WITH_VERSION);
27770
+ const path4 = join13(getOpenCodeCacheDir(), "packages", PLUGIN_ENTRY_WITH_VERSION);
27763
27771
  let cached2;
27764
27772
  try {
27765
- const installedPkgPath = join12(path4, "node_modules", "@cortexkit", "opencode-magic-context", "package.json");
27773
+ const installedPkgPath = join13(path4, "node_modules", "@cortexkit", "opencode-magic-context", "package.json");
27766
27774
  if (existsSync14(installedPkgPath)) {
27767
27775
  const pkg = JSON.parse(readFileSync9(installedPkgPath, "utf-8"));
27768
27776
  cached2 = typeof pkg.version === "string" ? pkg.version : undefined;
@@ -27773,8 +27781,8 @@ function getPluginCacheInfo() {
27773
27781
  return { path: path4, cached: cached2, latest: getSelfVersion() };
27774
27782
  }
27775
27783
  function getStorageDir() {
27776
- const dataHome = process.env.XDG_DATA_HOME || join12(homedir8(), ".local", "share");
27777
- return join12(dataHome, "cortexkit", "magic-context");
27784
+ const dataHome = process.env.XDG_DATA_HOME || join13(homedir9(), ".local", "share");
27785
+ return join13(dataHome, "cortexkit", "magic-context");
27778
27786
  }
27779
27787
  function fileSize(path4) {
27780
27788
  try {
@@ -27787,7 +27795,7 @@ function escapeRegex2(value) {
27787
27795
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
27788
27796
  }
27789
27797
  function sanitizeString(value) {
27790
- const home = homedir8();
27798
+ const home = homedir9();
27791
27799
  const username = userInfo().username;
27792
27800
  let sanitized = value;
27793
27801
  if (home) {
@@ -27871,13 +27879,13 @@ function parseHistorianDumpMeta(path4) {
27871
27879
  }
27872
27880
  }
27873
27881
  function collectHistorianDumps() {
27874
- const dir = join12(tmpdir3(), "magic-context-historian");
27882
+ const dir = join13(tmpdir3(), "magic-context-historian");
27875
27883
  if (!existsSync14(dir)) {
27876
27884
  return { dir, count: 0, recent: [] };
27877
27885
  }
27878
27886
  try {
27879
27887
  const entries = readdirSync2(dir).filter((name) => name.endsWith(".xml")).map((name) => {
27880
- const stat = statSync2(join12(dir, name));
27888
+ const stat = statSync2(join13(dir, name));
27881
27889
  return {
27882
27890
  name,
27883
27891
  mtime: stat.mtimeMs,
@@ -27886,7 +27894,7 @@ function collectHistorianDumps() {
27886
27894
  }).sort((a, b2) => b2.mtime - a.mtime);
27887
27895
  const now = Date.now();
27888
27896
  const recent = entries.slice(0, 5).map((entry) => {
27889
- const meta3 = parseHistorianDumpMeta(join12(dir, entry.name));
27897
+ const meta3 = parseHistorianDumpMeta(join13(dir, entry.name));
27890
27898
  const summary = {
27891
27899
  name: entry.name,
27892
27900
  ageMinutes: Math.round((now - entry.mtime) / 60000),
@@ -27905,7 +27913,7 @@ function collectHistorianDumps() {
27905
27913
  }
27906
27914
  }
27907
27915
  async function collectHistorianFailures(storageDirPath) {
27908
- const contextDbPath = join12(storageDirPath, "context.db");
27916
+ const contextDbPath = join13(storageDirPath, "context.db");
27909
27917
  if (!existsSync14(contextDbPath))
27910
27918
  return [];
27911
27919
  if (typeof globalThis.Bun === "undefined") {
@@ -27945,8 +27953,8 @@ async function collectDiagnostics() {
27945
27953
  const tuiConfig = readConfig2(configPaths.tuiConfig);
27946
27954
  const magicContextConfig = readConfig2(configPaths.magicContextConfig);
27947
27955
  const storageDirPath = getStorageDir();
27948
- const contextDbPath = join12(storageDirPath, "context.db");
27949
- const logPath = join12(tmpdir3(), "magic-context.log");
27956
+ const contextDbPath = join13(storageDirPath, "context.db");
27957
+ const logPath = join13(tmpdir3(), "magic-context.log");
27950
27958
  const logFileSize = existsSync14(logPath) ? statSync2(logPath).size : 0;
27951
27959
  const conflictResult = detectConflicts(process.cwd());
27952
27960
  return {
@@ -28079,13 +28087,13 @@ var init_diagnostics_opencode = __esm(() => {
28079
28087
 
28080
28088
  // src/lib/logs-opencode.ts
28081
28089
  import { readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "node:fs";
28082
- import { homedir as homedir9, userInfo as userInfo2 } from "node:os";
28083
- import { join as join13 } from "node:path";
28090
+ import { homedir as homedir10, userInfo as userInfo2 } from "node:os";
28091
+ import { join as join14 } from "node:path";
28084
28092
  function escapeRegex3(value) {
28085
28093
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
28086
28094
  }
28087
28095
  function sanitizeLogContent(content) {
28088
- const home = homedir9();
28096
+ const home = homedir10();
28089
28097
  const username = userInfo2().username;
28090
28098
  let sanitized = content;
28091
28099
  if (home) {
@@ -28140,7 +28148,7 @@ async function bundleIssueReport(report, description, _title) {
28140
28148
  `));
28141
28149
  const historianFailureLines = extractHistorianFailureLines(historianScanWindow, 30);
28142
28150
  const configBody = JSON.stringify(report.magicContextConfig.flags, null, 2);
28143
- const sanitizedConfigPath = report.configPaths.magicContextConfig.replace(homedir9(), "~");
28151
+ const sanitizedConfigPath = report.configPaths.magicContextConfig.replace(homedir10(), "~");
28144
28152
  const bodyMarkdown = [
28145
28153
  "## Description",
28146
28154
  description,
@@ -28171,7 +28179,7 @@ async function bundleIssueReport(report, description, _title) {
28171
28179
  "```"
28172
28180
  ].join(`
28173
28181
  `);
28174
- const path4 = join13(process.cwd(), `magic-context-issue-${formatTimestamp(new Date)}.md`);
28182
+ const path4 = join14(process.cwd(), `magic-context-issue-${formatTimestamp(new Date)}.md`);
28175
28183
  writeFileSync9(path4, `${bodyMarkdown}
28176
28184
  `);
28177
28185
  return { path: path4, bodyMarkdown };
@@ -28258,11 +28266,11 @@ var init_logs_opencode = __esm(() => {
28258
28266
  });
28259
28267
 
28260
28268
  // src/commands/doctor-opencode.ts
28261
- import { execSync as execSync3, spawnSync as spawnSync2 } from "node:child_process";
28269
+ import { execSync as execSync2, spawnSync as spawnSync2 } from "node:child_process";
28262
28270
  import { existsSync as existsSync15, readdirSync as readdirSync3, readFileSync as readFileSync11, rmSync, statSync as statSync3, writeFileSync as writeFileSync10 } from "node:fs";
28263
28271
  import { createRequire as createRequire4 } from "node:module";
28264
- import { homedir as homedir10, tmpdir as tmpdir4 } from "node:os";
28265
- import { join as join14 } from "node:path";
28272
+ import { homedir as homedir11, tmpdir as tmpdir4 } from "node:os";
28273
+ import { join as join15 } from "node:path";
28266
28274
  async function fetchNpmLatest(pkg, timeoutMs = 5000) {
28267
28275
  try {
28268
28276
  const controller = new AbortController;
@@ -28312,13 +28320,13 @@ function compareVersions(a, b2) {
28312
28320
  }
28313
28321
  async function clearPluginCache(force = false) {
28314
28322
  const cacheDir = getOpenCodeCacheDir();
28315
- const pluginCacheDir = join14(cacheDir, "packages", PLUGIN_ENTRY_WITH_VERSION2);
28323
+ const pluginCacheDir = join15(cacheDir, "packages", PLUGIN_ENTRY_WITH_VERSION2);
28316
28324
  if (!existsSync15(pluginCacheDir)) {
28317
28325
  return { action: "not_found", path: pluginCacheDir };
28318
28326
  }
28319
28327
  let cachedVersion;
28320
28328
  try {
28321
- const installedPkgPath = join14(pluginCacheDir, "node_modules", "@cortexkit", "opencode-magic-context", "package.json");
28329
+ const installedPkgPath = join15(pluginCacheDir, "node_modules", "@cortexkit", "opencode-magic-context", "package.json");
28322
28330
  if (existsSync15(installedPkgPath)) {
28323
28331
  const pkg = JSON.parse(readFileSync11(installedPkgPath, "utf-8"));
28324
28332
  if (typeof pkg?.version === "string") {
@@ -28358,7 +28366,7 @@ async function clearPluginCache(force = false) {
28358
28366
  }
28359
28367
  function isGhInstalled() {
28360
28368
  try {
28361
- execSync3("gh --version", { stdio: "pipe" });
28369
+ execSync2("gh --version", { stdio: "pipe" });
28362
28370
  return true;
28363
28371
  } catch {
28364
28372
  return false;
@@ -28840,7 +28848,7 @@ async function runDoctor(options = {}) {
28840
28848
  failCount += embeddingCheck.issues;
28841
28849
  else
28842
28850
  passCount++;
28843
- const dbPath = join14(getMagicContextStorageDir(), "context.db");
28851
+ const dbPath = join15(getMagicContextStorageDir(), "context.db");
28844
28852
  if (!existsSync15(dbPath)) {
28845
28853
  log.info(`Shared context DB not yet created at ${dbPath} (will be created on first run)`);
28846
28854
  } else {
@@ -28902,7 +28910,7 @@ async function runDoctor(options = {}) {
28902
28910
  }
28903
28911
  {
28904
28912
  const ageWarnings = [];
28905
- const npmrcPath = join14(homedir10(), ".npmrc");
28913
+ const npmrcPath = join15(homedir11(), ".npmrc");
28906
28914
  if (existsSync15(npmrcPath)) {
28907
28915
  try {
28908
28916
  const npmrc = readFileSync11(npmrcPath, "utf-8");
@@ -28928,7 +28936,7 @@ async function runDoctor(options = {}) {
28928
28936
  issues++;
28929
28937
  }
28930
28938
  }
28931
- const logPath = join14(tmpdir4(), "magic-context.log");
28939
+ const logPath = join15(tmpdir4(), "magic-context.log");
28932
28940
  if (existsSync15(logPath)) {
28933
28941
  const logStat = statSync3(logPath);
28934
28942
  const sizeKb = (logStat.size / 1024).toFixed(0);
@@ -28936,12 +28944,12 @@ async function runDoctor(options = {}) {
28936
28944
  } else {
28937
28945
  log.info(`Log file: ${logPath} (not yet created)`);
28938
28946
  }
28939
- const historianDumpDir = join14(tmpdir4(), "magic-context-historian");
28947
+ const historianDumpDir = join15(tmpdir4(), "magic-context-historian");
28940
28948
  if (existsSync15(historianDumpDir)) {
28941
28949
  try {
28942
28950
  const dumps = readdirSync3(historianDumpDir).filter((f) => f.endsWith(".xml")).map((f) => ({
28943
28951
  name: f,
28944
- mtime: statSync3(join14(historianDumpDir, f)).mtimeMs
28952
+ mtime: statSync3(join15(historianDumpDir, f)).mtimeMs
28945
28953
  })).sort((a, b2) => b2.mtime - a.mtime);
28946
28954
  if (dumps.length > 0) {
28947
28955
  warn(`Historian debug dumps: ${dumps.length} file(s) in ${historianDumpDir}`);
@@ -161896,6 +161904,25 @@ var init_migrations = __esm(async () => {
161896
161904
  WHERE type = 'tool' AND tool_owner_message_id IS NULL;
161897
161905
  `);
161898
161906
  }
161907
+ },
161908
+ {
161909
+ version: 11,
161910
+ description: "Add todo state synthesis columns to session_meta",
161911
+ up: (db) => {
161912
+ const cols = db.prepare("PRAGMA table_info(session_meta)").all();
161913
+ if (!cols.some((c2) => c2.name === "last_todo_state")) {
161914
+ db.exec("ALTER TABLE session_meta ADD COLUMN last_todo_state TEXT DEFAULT ''");
161915
+ }
161916
+ if (!cols.some((c2) => c2.name === "todo_synthetic_call_id")) {
161917
+ db.exec("ALTER TABLE session_meta ADD COLUMN todo_synthetic_call_id TEXT DEFAULT ''");
161918
+ }
161919
+ if (!cols.some((c2) => c2.name === "todo_synthetic_anchor_message_id")) {
161920
+ db.exec("ALTER TABLE session_meta ADD COLUMN todo_synthetic_anchor_message_id TEXT DEFAULT ''");
161921
+ }
161922
+ if (!cols.some((c2) => c2.name === "todo_synthetic_state_json")) {
161923
+ db.exec("ALTER TABLE session_meta ADD COLUMN todo_synthetic_state_json TEXT DEFAULT ''");
161924
+ }
161925
+ }
161899
161926
  }
161900
161927
  ];
161901
161928
  });
@@ -161935,9 +161962,9 @@ var init_tool_definition_tokens = __esm(() => {
161935
161962
 
161936
161963
  // ../plugin/src/features/magic-context/tool-owner-backfill.ts
161937
161964
  import { existsSync as existsSync16 } from "node:fs";
161938
- import { join as join15 } from "node:path";
161965
+ import { join as join16 } from "node:path";
161939
161966
  function resolveOpencodeDbPath() {
161940
- return join15(getDataDir(), "opencode", "opencode.db");
161967
+ return join16(getDataDir(), "opencode", "opencode.db");
161941
161968
  }
161942
161969
  function ensureBackfillStateTable(db) {
161943
161970
  db.exec(`
@@ -162183,23 +162210,23 @@ var init_tool_owner_backfill = __esm(() => {
162183
162210
 
162184
162211
  // ../plugin/src/features/magic-context/storage-db.ts
162185
162212
  import { copyFileSync, cpSync, existsSync as existsSync17, mkdirSync as mkdirSync7 } from "node:fs";
162186
- import { join as join16 } from "node:path";
162213
+ import { join as join17 } from "node:path";
162187
162214
  function resolveDatabasePath() {
162188
162215
  const dbDir = getMagicContextStorageDir();
162189
- return { dbDir, dbPath: join16(dbDir, "context.db") };
162216
+ return { dbDir, dbPath: join17(dbDir, "context.db") };
162190
162217
  }
162191
162218
  function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
162192
162219
  if (existsSync17(targetDbPath))
162193
162220
  return;
162194
162221
  const legacyDir = getLegacyOpenCodeMagicContextStorageDir();
162195
- const legacyDbPath = join16(legacyDir, "context.db");
162222
+ const legacyDbPath = join17(legacyDir, "context.db");
162196
162223
  if (!existsSync17(legacyDbPath))
162197
162224
  return;
162198
162225
  log2(`[magic-context] migrating legacy plugin storage: ${legacyDir} -> ${targetDbDir} (legacy left in place as backup)`);
162199
162226
  mkdirSync7(targetDbDir, { recursive: true });
162200
162227
  for (const suffix of ["", "-wal", "-shm"]) {
162201
162228
  const src = `${legacyDbPath}${suffix}`;
162202
- const dst = join16(targetDbDir, `context.db${suffix}`);
162229
+ const dst = join17(targetDbDir, `context.db${suffix}`);
162203
162230
  if (existsSync17(src)) {
162204
162231
  try {
162205
162232
  copyFileSync(src, dst);
@@ -162208,8 +162235,8 @@ function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
162208
162235
  }
162209
162236
  }
162210
162237
  }
162211
- const legacyModelsDir = join16(legacyDir, "models");
162212
- const targetModelsDir = join16(targetDbDir, "models");
162238
+ const legacyModelsDir = join17(legacyDir, "models");
162239
+ const targetModelsDir = join17(targetDbDir, "models");
162213
162240
  if (existsSync17(legacyModelsDir) && !existsSync17(targetModelsDir)) {
162214
162241
  try {
162215
162242
  cpSync(legacyModelsDir, targetModelsDir, { recursive: true });
@@ -162411,6 +162438,10 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
162411
162438
  note_nudge_trigger_message_id TEXT DEFAULT '',
162412
162439
  note_nudge_sticky_text TEXT DEFAULT '',
162413
162440
  note_nudge_sticky_message_id TEXT DEFAULT '',
162441
+ last_todo_state TEXT DEFAULT '',
162442
+ todo_synthetic_call_id TEXT DEFAULT '',
162443
+ todo_synthetic_anchor_message_id TEXT DEFAULT '',
162444
+ todo_synthetic_state_json TEXT DEFAULT '',
162414
162445
  is_subagent INTEGER DEFAULT 0,
162415
162446
  last_context_percentage REAL DEFAULT 0,
162416
162447
  last_input_tokens INTEGER DEFAULT 0,
@@ -162475,6 +162506,10 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
162475
162506
  ensureColumn(db, "session_meta", "note_nudge_trigger_message_id", "TEXT DEFAULT ''");
162476
162507
  ensureColumn(db, "session_meta", "note_nudge_sticky_text", "TEXT DEFAULT ''");
162477
162508
  ensureColumn(db, "session_meta", "note_nudge_sticky_message_id", "TEXT DEFAULT ''");
162509
+ ensureColumn(db, "session_meta", "last_todo_state", "TEXT DEFAULT ''");
162510
+ ensureColumn(db, "session_meta", "todo_synthetic_call_id", "TEXT DEFAULT ''");
162511
+ ensureColumn(db, "session_meta", "todo_synthetic_anchor_message_id", "TEXT DEFAULT ''");
162512
+ ensureColumn(db, "session_meta", "todo_synthetic_state_json", "TEXT DEFAULT ''");
162478
162513
  ensureColumn(db, "session_meta", "note_last_read_at", "INTEGER DEFAULT 0");
162479
162514
  ensureColumn(db, "session_meta", "times_execute_threshold_reached", "INTEGER DEFAULT 0");
162480
162515
  ensureColumn(db, "session_meta", "compartment_in_progress", "INTEGER DEFAULT 0");
@@ -162539,6 +162574,10 @@ function healNullTextColumns(db) {
162539
162574
  ["note_nudge_trigger_message_id", ""],
162540
162575
  ["note_nudge_sticky_text", ""],
162541
162576
  ["note_nudge_sticky_message_id", ""],
162577
+ ["last_todo_state", ""],
162578
+ ["todo_synthetic_call_id", ""],
162579
+ ["todo_synthetic_anchor_message_id", ""],
162580
+ ["todo_synthetic_state_json", ""],
162542
162581
  ["system_prompt_hash", ""],
162543
162582
  ["stripped_placeholder_ids", ""],
162544
162583
  ["memory_block_cache", ""],
@@ -162734,15 +162773,15 @@ var init_storage = __esm(async () => {
162734
162773
 
162735
162774
  // ../pi-plugin/src/config/index.ts
162736
162775
  import { existsSync as existsSync18, readFileSync as readFileSync12 } from "node:fs";
162737
- import { homedir as homedir11 } from "node:os";
162738
- import { join as join17 } from "node:path";
162776
+ import { homedir as homedir12 } from "node:os";
162777
+ import { join as join18 } from "node:path";
162739
162778
  function getProjectConfigPaths(cwd) {
162740
- const basePath = join17(cwd, ".pi", CONFIG_FILE_NAME);
162779
+ const basePath = join18(cwd, ".pi", CONFIG_FILE_NAME);
162741
162780
  return [`${basePath}.jsonc`, `${basePath}.json`];
162742
162781
  }
162743
162782
  function getUserConfigPaths() {
162744
- const home = process.env.HOME ?? homedir11();
162745
- const basePath = join17(home, ".pi", "agent", CONFIG_FILE_NAME);
162783
+ const home = process.env.HOME ?? homedir12();
162784
+ const basePath = join18(home, ".pi", "agent", CONFIG_FILE_NAME);
162746
162785
  return [`${basePath}.jsonc`, `${basePath}.json`];
162747
162786
  }
162748
162787
  function resolveFirstExisting(paths) {
@@ -162882,8 +162921,8 @@ var init_config2 = __esm(() => {
162882
162921
  import { createHash } from "node:crypto";
162883
162922
  import { existsSync as existsSync19, readFileSync as readFileSync13, statSync as statSync4 } from "node:fs";
162884
162923
  import { createRequire as createRequire5 } from "node:module";
162885
- import { homedir as homedir12, tmpdir as tmpdir5, userInfo as userInfo3 } from "node:os";
162886
- import { join as join18 } from "node:path";
162924
+ import { homedir as homedir13, tmpdir as tmpdir5, userInfo as userInfo3 } from "node:os";
162925
+ import { join as join19 } from "node:path";
162887
162926
  function getSelfVersion3() {
162888
162927
  const req = createRequire5(import.meta.url);
162889
162928
  for (const relPath of ["../../package.json", "../package.json"]) {
@@ -162914,7 +162953,7 @@ function redactSecretString(value) {
162914
162953
  return value.replace(/Bearer\s+[A-Za-z0-9._~+\-/=]+/g, "Bearer <REDACTED>").replace(/sk-[A-Za-z0-9_-]{12,}/g, "sk-<REDACTED>").replace(/api[_-]?key=([^\s&]+)/gi, "api_key=<REDACTED>").replace(/token=([^\s&]+)/gi, "token=<REDACTED>");
162915
162954
  }
162916
162955
  function sanitizeString2(value) {
162917
- const home = process.env.HOME || homedir12();
162956
+ const home = process.env.HOME || homedir13();
162918
162957
  const username = userInfo3().username;
162919
162958
  const userHash = `<USER:${currentUserHash()}>`;
162920
162959
  let sanitized = redactSecretString(value);
@@ -162962,7 +163001,7 @@ function readJsonc3(path4) {
162962
163001
  }
162963
163002
  }
162964
163003
  function getProjectConfigPath(cwd) {
162965
- return join18(cwd, ".pi", "magic-context.jsonc");
163004
+ return join19(cwd, ".pi", "magic-context.jsonc");
162966
163005
  }
162967
163006
  function readConfigDiagnostic(path4) {
162968
163007
  const parsed = readJsonc3(path4);
@@ -162988,8 +163027,8 @@ async function collectDiagnostics2(cwd = process.cwd()) {
162988
163027
  const projectConfigPath = getProjectConfigPath(cwd);
162989
163028
  const loaded = loadPiConfig({ cwd });
162990
163029
  const storageDirPath = getMagicContextStorageDir();
162991
- const dbPath = join18(storageDirPath, "context.db");
162992
- const logPath = join18(tmpdir5(), "magic-context.log");
163030
+ const dbPath = join19(storageDirPath, "context.db");
163031
+ const logPath = join19(tmpdir5(), "magic-context.log");
162993
163032
  const logFileSize = existsSync19(logPath) ? statSync4(logPath).size : 0;
162994
163033
  const otherPiExtensions = packages.filter((entry) => !hasMagicContextPackage([entry]));
162995
163034
  return {
@@ -163118,7 +163157,7 @@ var init_diagnostics_pi = __esm(() => {
163118
163157
 
163119
163158
  // src/lib/logs-pi.ts
163120
163159
  import { readFileSync as readFileSync14, writeFileSync as writeFileSync11 } from "node:fs";
163121
- import { join as join19 } from "node:path";
163160
+ import { join as join20 } from "node:path";
163122
163161
  function sanitizeLogContent2(content) {
163123
163162
  return sanitizeString2(content);
163124
163163
  }
@@ -163162,7 +163201,7 @@ async function bundleIssueReport2(report, description, title, options = {}) {
163162
163201
  ].join(`
163163
163202
  `);
163164
163203
  const cwd = options.cwd ?? process.cwd();
163165
- const path4 = join19(cwd, `magic-context-pi-issue-${formatTimestamp2(options.now ?? new Date)}.md`);
163204
+ const path4 = join20(cwd, `magic-context-pi-issue-${formatTimestamp2(options.now ?? new Date)}.md`);
163166
163205
  writeFileSync11(path4, `${bodyMarkdown}
163167
163206
  `);
163168
163207
  return { path: path4, bodyMarkdown };
@@ -163172,7 +163211,7 @@ var init_logs_pi = __esm(() => {
163172
163211
  });
163173
163212
 
163174
163213
  // src/commands/doctor-pi.ts
163175
- import { execFileSync as execFileSync3, spawnSync as spawnSync3 } from "node:child_process";
163214
+ import { execFileSync as execFileSync4, spawnSync as spawnSync3 } from "node:child_process";
163176
163215
  import {
163177
163216
  existsSync as existsSync20,
163178
163217
  mkdirSync as mkdirSync8,
@@ -163183,8 +163222,8 @@ import {
163183
163222
  writeFileSync as writeFileSync12
163184
163223
  } from "node:fs";
163185
163224
  import { createRequire as createRequire6 } from "node:module";
163186
- import { homedir as homedir13, tmpdir as tmpdir6 } from "node:os";
163187
- import { dirname as dirname9, join as join20 } from "node:path";
163225
+ import { homedir as homedir14, tmpdir as tmpdir6 } from "node:os";
163226
+ import { dirname as dirname9, join as join21 } from "node:path";
163188
163227
  function depsFrom(options) {
163189
163228
  return {
163190
163229
  ...DEFAULT_DEPS,
@@ -163217,7 +163256,7 @@ function selfVersion() {
163217
163256
  }
163218
163257
  function getLatestNpmVersion(packageName) {
163219
163258
  try {
163220
- return execFileSync3("npm", ["view", packageName, "version"], {
163259
+ return execFileSync4("npm", ["view", packageName, "version"], {
163221
163260
  encoding: "utf-8",
163222
163261
  stdio: ["ignore", "pipe", "ignore"],
163223
163262
  timeout: 1e4
@@ -163287,7 +163326,7 @@ function hasPiPackage(packages) {
163287
163326
  return packages.some((entry) => entry === PI_PACKAGE_SOURCE || entry === PACKAGE_NAME2 || entry.includes("pi-magic-context"));
163288
163327
  }
163289
163328
  function projectConfigPath(cwd) {
163290
- return join20(cwd, ".pi", "magic-context.jsonc");
163329
+ return join21(cwd, ".pi", "magic-context.jsonc");
163291
163330
  }
163292
163331
  function readConfigForEmbedding(path4) {
163293
163332
  if (!existsSync20(path4))
@@ -163351,14 +163390,14 @@ function countTable(db, table) {
163351
163390
  }
163352
163391
  }
163353
163392
  function cacheRoots() {
163354
- const home = homedir13();
163355
- const cacheHome = process.env.XDG_CACHE_HOME || join20(home, ".cache");
163393
+ const home = homedir14();
163394
+ const cacheHome = process.env.XDG_CACHE_HOME || join21(home, ".cache");
163356
163395
  return [
163357
- join20(home, ".pi", "cache", "extensions"),
163358
- join20(home, ".pi", "cache", "packages"),
163359
- join20(cacheHome, "pi", "extensions"),
163360
- join20(cacheHome, "pi", "packages"),
163361
- join20(getPiAgentConfigDir(), "cache", "extensions")
163396
+ join21(home, ".pi", "cache", "extensions"),
163397
+ join21(home, ".pi", "cache", "packages"),
163398
+ join21(cacheHome, "pi", "extensions"),
163399
+ join21(cacheHome, "pi", "packages"),
163400
+ join21(getPiAgentConfigDir(), "cache", "extensions")
163362
163401
  ];
163363
163402
  }
163364
163403
  function findPiMagicContextCacheDirs(self, force = false) {
@@ -163374,7 +163413,7 @@ function findPiMagicContextCacheDirs(self, force = false) {
163374
163413
  }
163375
163414
  if (!stat.isDirectory())
163376
163415
  return;
163377
- const packageJson = join20(path4, "package.json");
163416
+ const packageJson = join21(path4, "package.json");
163378
163417
  if (existsSync20(packageJson)) {
163379
163418
  try {
163380
163419
  const pkg = JSON.parse(readFileSync15(packageJson, "utf-8"));
@@ -163396,7 +163435,7 @@ function findPiMagicContextCacheDirs(self, force = false) {
163396
163435
  return;
163397
163436
  }
163398
163437
  for (const entry of entries)
163399
- visit(join20(path4, entry), depth - 1);
163438
+ visit(join21(path4, entry), depth - 1);
163400
163439
  };
163401
163440
  for (const root of cacheRoots())
163402
163441
  visit(root, 5);
@@ -163490,7 +163529,7 @@ async function runHealthChecks(options) {
163490
163529
  add(results, "pass", `historian.model "${historianModel}" has thinking_level "${historianThinkingLevel}" configured`);
163491
163530
  }
163492
163531
  const storageDir = getMagicContextStorageDir();
163493
- const dbPath = join20(storageDir, "context.db");
163532
+ const dbPath = join21(storageDir, "context.db");
163494
163533
  const existedBeforeOpen = existsSync20(dbPath);
163495
163534
  if (existedBeforeOpen)
163496
163535
  add(results, "pass", `Shared context DB exists at ${dbPath}`);
@@ -163567,7 +163606,7 @@ async function runHealthChecks(options) {
163567
163606
  } else {
163568
163607
  add(results, "pass", "Pi extension cache clean (no stale cached package found)");
163569
163608
  }
163570
- const logPath = join20(tmpdir6(), "magic-context.log");
163609
+ const logPath = join21(tmpdir6(), "magic-context.log");
163571
163610
  if (existsSync20(logPath)) {
163572
163611
  const stat = statSync5(logPath);
163573
163612
  const sizeKb = (stat.size / 1024).toFixed(0);
@@ -163577,10 +163616,10 @@ async function runHealthChecks(options) {
163577
163616
  } else {
163578
163617
  add(results, "info", `No plugin log file yet at ${logPath}`);
163579
163618
  }
163580
- const historianDumpDir = join20(tmpdir6(), "magic-context-historian");
163619
+ const historianDumpDir = join21(tmpdir6(), "magic-context-historian");
163581
163620
  if (existsSync20(historianDumpDir)) {
163582
163621
  try {
163583
- const dumps = readdirSync4(historianDumpDir).filter((f) => f.endsWith(".xml")).map((f) => ({ name: f, mtime: statSync5(join20(historianDumpDir, f)).mtimeMs })).sort((a, b2) => b2.mtime - a.mtime);
163622
+ const dumps = readdirSync4(historianDumpDir).filter((f) => f.endsWith(".xml")).map((f) => ({ name: f, mtime: statSync5(join21(historianDumpDir, f)).mtimeMs })).sort((a, b2) => b2.mtime - a.mtime);
163584
163623
  if (dumps.length > 0) {
163585
163624
  add(results, "warn", `Historian debug dumps: ${dumps.length} file(s) in ${historianDumpDir}`);
163586
163625
  for (const dump of dumps.slice(0, 3)) {
@@ -163774,7 +163813,7 @@ var init_doctor_pi = __esm(async () => {
163774
163813
  isDatabasePersisted,
163775
163814
  closeDatabase,
163776
163815
  now: () => new Date,
163777
- execFileSync: execFileSync3,
163816
+ execFileSync: execFileSync4,
163778
163817
  spawnSync: spawnSync3
163779
163818
  };
163780
163819
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/magic-context",
3
- "version": "0.17.2",
3
+ "version": "0.18.0",
4
4
  "description": "Unified CLI for Magic Context — setup, doctor, and migration across OpenCode and Pi",
5
5
  "keywords": [
6
6
  "opencode",