@cortexkit/opencode-magic-context 0.5.0 → 0.5.1

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.
package/dist/cli.js CHANGED
@@ -7849,8 +7849,8 @@ var require_src3 = __commonJS((exports, module) => {
7849
7849
  });
7850
7850
 
7851
7851
  // src/cli/doctor.ts
7852
- var import_comment_json3 = __toESM(require_src2(), 1);
7853
- import { existsSync as existsSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
7852
+ var import_comment_json2 = __toESM(require_src2(), 1);
7853
+ import { existsSync as existsSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "node:fs";
7854
7854
 
7855
7855
  // src/shared/conflict-detector.ts
7856
7856
  import { join as join2 } from "node:path";
@@ -8152,8 +8152,7 @@ function readOmoDisabledHooks(directory) {
8152
8152
  }
8153
8153
 
8154
8154
  // src/shared/conflict-fixer.ts
8155
- var import_comment_json = __toESM(require_src2(), 1);
8156
- import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
8155
+ import { existsSync as existsSync2, mkdirSync, writeFileSync } from "node:fs";
8157
8156
  import { dirname, join as join3 } from "node:path";
8158
8157
  var CONFLICTING_OMO_HOOKS = [
8159
8158
  "context-window-monitor",
@@ -8179,16 +8178,11 @@ function readConfig(filePath) {
8179
8178
  if (!existsSync2(filePath)) {
8180
8179
  return {};
8181
8180
  }
8182
- try {
8183
- const raw = readFileSync2(filePath, "utf-8");
8184
- return import_comment_json.parse(raw);
8185
- } catch {
8186
- return null;
8187
- }
8181
+ return readJsoncFile(filePath);
8188
8182
  }
8189
8183
  function writeConfig(filePath, config) {
8190
8184
  ensureParentDir(filePath);
8191
- writeFileSync(filePath, `${import_comment_json.stringify(config, null, 2)}
8185
+ writeFileSync(filePath, `${JSON.stringify(config, null, 2)}
8192
8186
  `);
8193
8187
  }
8194
8188
  function resolveUserOpenCodeConfigPath() {
@@ -8318,8 +8312,8 @@ function fixConflicts(directory, conflicts) {
8318
8312
  }
8319
8313
 
8320
8314
  // src/shared/tui-config.ts
8321
- var import_comment_json2 = __toESM(require_src2(), 1);
8322
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
8315
+ var import_comment_json = __toESM(require_src2(), 1);
8316
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
8323
8317
  import { dirname as dirname2, join as join5 } from "node:path";
8324
8318
 
8325
8319
  // src/shared/logger.ts
@@ -8389,8 +8383,8 @@ function ensureTuiPluginEntry() {
8389
8383
  const configPath = resolveTuiConfigPath();
8390
8384
  let config = {};
8391
8385
  if (existsSync3(configPath)) {
8392
- const raw = readFileSync3(configPath, "utf-8");
8393
- config = import_comment_json2.parse(raw) ?? {};
8386
+ const raw = readFileSync2(configPath, "utf-8");
8387
+ config = import_comment_json.parse(raw) ?? {};
8394
8388
  }
8395
8389
  const plugins = Array.isArray(config.plugin) ? config.plugin.filter((p) => typeof p === "string") : [];
8396
8390
  if (plugins.some((p) => p === PLUGIN_NAME || p.startsWith(`${PLUGIN_NAME}@`))) {
@@ -8399,7 +8393,7 @@ function ensureTuiPluginEntry() {
8399
8393
  plugins.push(PLUGIN_NAME);
8400
8394
  config.plugin = plugins;
8401
8395
  mkdirSync2(dirname2(configPath), { recursive: true });
8402
- writeFileSync2(configPath, `${import_comment_json2.stringify(config, null, 2)}
8396
+ writeFileSync2(configPath, `${import_comment_json.stringify(config, null, 2)}
8403
8397
  `);
8404
8398
  log(`[magic-context] added TUI plugin entry to ${configPath}`);
8405
8399
  return true;
@@ -9626,8 +9620,8 @@ async function runDoctor() {
9626
9620
  }
9627
9621
  if (paths.opencodeConfigFormat !== "none") {
9628
9622
  try {
9629
- const raw = readFileSync4(paths.opencodeConfig, "utf-8");
9630
- const config = import_comment_json3.parse(raw);
9623
+ const raw = readFileSync3(paths.opencodeConfig, "utf-8");
9624
+ const config = import_comment_json2.parse(raw);
9631
9625
  const plugins = Array.isArray(config?.plugin) ? config.plugin : [];
9632
9626
  const hasPlugin = plugins.some((p) => typeof p === "string" && (p === PLUGIN_NAME2 || p.startsWith(`${PLUGIN_NAME2}@`) || p.includes("opencode-magic-context")));
9633
9627
  const configName = paths.opencodeConfigFormat === "jsonc" ? "opencode.jsonc" : "opencode.json";
@@ -9636,7 +9630,7 @@ async function runDoctor() {
9636
9630
  } else {
9637
9631
  const updatedPlugins = [...plugins, PLUGIN_NAME2];
9638
9632
  config.plugin = updatedPlugins;
9639
- writeFileSync3(paths.opencodeConfig, `${import_comment_json3.stringify(config, null, 2)}
9633
+ writeFileSync3(paths.opencodeConfig, `${import_comment_json2.stringify(config, null, 2)}
9640
9634
  `);
9641
9635
  R2.success(`Added plugin to ${configName}`);
9642
9636
  fixed++;
@@ -9693,8 +9687,8 @@ async function runDoctor() {
9693
9687
  }
9694
9688
 
9695
9689
  // src/cli/setup.ts
9696
- var import_comment_json4 = __toESM(require_src2(), 1);
9697
- import { existsSync as existsSync6, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
9690
+ var import_comment_json3 = __toESM(require_src2(), 1);
9691
+ import { existsSync as existsSync6, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
9698
9692
  import { dirname as dirname3 } from "node:path";
9699
9693
  var PLUGIN_NAME3 = "@cortexkit/opencode-magic-context";
9700
9694
  function ensureDir(dir) {
@@ -9703,9 +9697,9 @@ function ensureDir(dir) {
9703
9697
  }
9704
9698
  }
9705
9699
  function readJsonc(path2) {
9706
- const content = readFileSync5(path2, "utf-8");
9700
+ const content = readFileSync4(path2, "utf-8");
9707
9701
  try {
9708
- return import_comment_json4.parse(content);
9702
+ return import_comment_json3.parse(content);
9709
9703
  } catch (err) {
9710
9704
  console.error(` ⚠ Failed to parse ${path2}: ${err instanceof Error ? err.message : err}`);
9711
9705
  return null;
@@ -9718,7 +9712,7 @@ function addPluginToOpenCodeConfig(configPath, format) {
9718
9712
  plugin: [PLUGIN_NAME3],
9719
9713
  compaction: { auto: false, prune: false }
9720
9714
  };
9721
- writeFileSync4(configPath, `${import_comment_json4.stringify(config, null, 2)}
9715
+ writeFileSync4(configPath, `${import_comment_json3.stringify(config, null, 2)}
9722
9716
  `);
9723
9717
  return;
9724
9718
  }
@@ -9737,13 +9731,13 @@ function addPluginToOpenCodeConfig(configPath, format) {
9737
9731
  compaction.auto = false;
9738
9732
  compaction.prune = false;
9739
9733
  existing.compaction = compaction;
9740
- writeFileSync4(configPath, `${import_comment_json4.stringify(existing, null, 2)}
9734
+ writeFileSync4(configPath, `${import_comment_json3.stringify(existing, null, 2)}
9741
9735
  `);
9742
9736
  }
9743
9737
  function addPluginToTuiConfig(configPath, format) {
9744
9738
  ensureDir(dirname3(configPath));
9745
9739
  if (format === "none") {
9746
- writeFileSync4(configPath, `${import_comment_json4.stringify({ plugin: [PLUGIN_NAME3] }, null, 2)}
9740
+ writeFileSync4(configPath, `${import_comment_json3.stringify({ plugin: [PLUGIN_NAME3] }, null, 2)}
9747
9741
  `);
9748
9742
  return;
9749
9743
  }
@@ -9758,7 +9752,7 @@ function addPluginToTuiConfig(configPath, format) {
9758
9752
  plugins.push(PLUGIN_NAME3);
9759
9753
  }
9760
9754
  existing.plugin = plugins;
9761
- writeFileSync4(configPath, `${import_comment_json4.stringify(existing, null, 2)}
9755
+ writeFileSync4(configPath, `${import_comment_json3.stringify(existing, null, 2)}
9762
9756
  `);
9763
9757
  }
9764
9758
  function writeMagicContextConfig(configPath, options) {
@@ -9799,7 +9793,7 @@ function writeMagicContextConfig(configPath, options) {
9799
9793
  cacheTtl["anthropic/claude-opus-4-6"] = "59m";
9800
9794
  config.cache_ttl = cacheTtl;
9801
9795
  }
9802
- writeFileSync4(configPath, `${import_comment_json4.stringify(config, null, 2)}
9796
+ writeFileSync4(configPath, `${import_comment_json3.stringify(config, null, 2)}
9803
9797
  `);
9804
9798
  }
9805
9799
  async function runSetup() {
@@ -9846,7 +9840,7 @@ async function runSetup() {
9846
9840
  if (shouldRemove) {
9847
9841
  plugins.splice(dcpIndex, 1);
9848
9842
  ocConfig.plugin = plugins;
9849
- writeFileSync4(paths.opencodeConfig, `${import_comment_json4.stringify(ocConfig, null, 2)}
9843
+ writeFileSync4(paths.opencodeConfig, `${import_comment_json3.stringify(ocConfig, null, 2)}
9850
9844
  `);
9851
9845
  R2.success("Removed opencode-dcp from plugin list");
9852
9846
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"conflict-fixer.d.ts","sourceRoot":"","sources":["../../src/shared/conflict-fixer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAmG1D,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG,MAAM,EAAE,CAiHhG"}
1
+ {"version":3,"file":"conflict-fixer.d.ts","sourceRoot":"","sources":["../../src/shared/conflict-fixer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAmG1D,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG,MAAM,EAAE,CAiHhG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-magic-context",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",