@cortexkit/magic-context 0.16.1 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +86 -43
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7888,9 +7888,6 @@ function getMagicContextLogPath() {
|
|
|
7888
7888
|
return join(tmpdir(), "magic-context.log");
|
|
7889
7889
|
}
|
|
7890
7890
|
function getOpenCodePluginCacheDir() {
|
|
7891
|
-
if (process.platform === "win32") {
|
|
7892
|
-
return join(homedir(), "AppData", "Local", "opencode", "Cache", "packages");
|
|
7893
|
-
}
|
|
7894
7891
|
const xdg = process.env.XDG_CACHE_HOME || join(homedir(), ".cache");
|
|
7895
7892
|
return join(xdg, "opencode", "packages");
|
|
7896
7893
|
}
|
|
@@ -10508,12 +10505,13 @@ function addPluginToOpenCodeConfig(configPath, format) {
|
|
|
10508
10505
|
log.warn(`Could not parse ${configPath} — skipping to avoid data loss`);
|
|
10509
10506
|
return;
|
|
10510
10507
|
}
|
|
10511
|
-
const
|
|
10512
|
-
const
|
|
10513
|
-
|
|
10514
|
-
|
|
10508
|
+
const rawPlugins = Array.isArray(existing.plugin) ? existing.plugin : [];
|
|
10509
|
+
const hasNpmEntry = rawPlugins.some((p) => matchesPluginEntry(p, PLUGIN_NAME3));
|
|
10510
|
+
const hasDevEntry = rawPlugins.some((p) => isDevPathPluginEntry(p));
|
|
10511
|
+
if (!hasNpmEntry && !hasDevEntry) {
|
|
10512
|
+
rawPlugins.push(PLUGIN_ENTRY2);
|
|
10515
10513
|
}
|
|
10516
|
-
existing.plugin =
|
|
10514
|
+
existing.plugin = rawPlugins;
|
|
10517
10515
|
const compaction = existing.compaction ?? {};
|
|
10518
10516
|
compaction.auto = false;
|
|
10519
10517
|
compaction.prune = false;
|
|
@@ -10533,12 +10531,13 @@ function addPluginToTuiConfig(configPath, format) {
|
|
|
10533
10531
|
log.warn(`Could not parse ${configPath} — skipping to avoid data loss`);
|
|
10534
10532
|
return;
|
|
10535
10533
|
}
|
|
10536
|
-
const
|
|
10537
|
-
const
|
|
10538
|
-
|
|
10539
|
-
|
|
10534
|
+
const rawPlugins = Array.isArray(existing.plugin) ? existing.plugin : [];
|
|
10535
|
+
const hasNpmEntry = rawPlugins.some((p) => matchesPluginEntry(p, PLUGIN_NAME3));
|
|
10536
|
+
const hasDevEntry = rawPlugins.some((p) => isDevPathPluginEntry(p));
|
|
10537
|
+
if (!hasNpmEntry && !hasDevEntry) {
|
|
10538
|
+
rawPlugins.push(PLUGIN_ENTRY2);
|
|
10540
10539
|
}
|
|
10541
|
-
existing.plugin =
|
|
10540
|
+
existing.plugin = rawPlugins;
|
|
10542
10541
|
writeFileSync4(configPath, `${import_comment_json3.stringify(existing, null, 2)}
|
|
10543
10542
|
`);
|
|
10544
10543
|
}
|
|
@@ -10772,6 +10771,7 @@ var import_comment_json3, PLUGIN_NAME3 = "@cortexkit/opencode-magic-context", PL
|
|
|
10772
10771
|
var init_setup_opencode = __esm(() => {
|
|
10773
10772
|
init_conflict_detector();
|
|
10774
10773
|
init_conflict_fixer();
|
|
10774
|
+
init_opencode();
|
|
10775
10775
|
init_opencode_helpers();
|
|
10776
10776
|
init_paths();
|
|
10777
10777
|
init_prompts();
|
|
@@ -25721,6 +25721,13 @@ var init_magic_context = __esm(() => {
|
|
|
25721
25721
|
min_clusters: exports_external.number().min(1).default(3)
|
|
25722
25722
|
}).default({ enabled: true, min_clusters: 3 }),
|
|
25723
25723
|
compaction_markers: exports_external.boolean().default(true),
|
|
25724
|
+
system_prompt_injection: exports_external.object({
|
|
25725
|
+
enabled: exports_external.boolean().default(true),
|
|
25726
|
+
skip_signatures: exports_external.array(exports_external.string()).default(["<!-- magic-context: skip -->"])
|
|
25727
|
+
}).default({
|
|
25728
|
+
enabled: true,
|
|
25729
|
+
skip_signatures: ["<!-- magic-context: skip -->"]
|
|
25730
|
+
}),
|
|
25724
25731
|
compressor: exports_external.object({
|
|
25725
25732
|
enabled: exports_external.boolean().default(true),
|
|
25726
25733
|
min_compartment_ratio: exports_external.number().min(100).max(1e4).default(DEFAULT_COMPRESSOR_MIN_COMPARTMENT_RATIO),
|
|
@@ -27307,33 +27314,45 @@ async function runDoctor(options = {}) {
|
|
|
27307
27314
|
try {
|
|
27308
27315
|
const raw = readFileSync11(paths.opencodeConfig, "utf-8");
|
|
27309
27316
|
const config2 = import_comment_json7.parse(raw);
|
|
27310
|
-
const
|
|
27311
|
-
const
|
|
27312
|
-
const isDevPathEntry = (p) => p.startsWith("file://") || p.startsWith("/") || p.startsWith("./");
|
|
27313
|
-
const existingIdx = pluginList.findIndex((p) => p === PLUGIN_NAME6 || p.startsWith(`${PLUGIN_NAME6}@`) || isDevPathEntry(p) && p.includes("opencode-magic-context"));
|
|
27317
|
+
const rawPlugins = Array.isArray(config2?.plugin) ? config2.plugin : [];
|
|
27318
|
+
const existingIdx = rawPlugins.findIndex((entry) => matchesPluginEntry(entry, PLUGIN_NAME6) || isDevPathPluginEntry(entry));
|
|
27314
27319
|
const configName = paths.opencodeConfigFormat === "jsonc" ? "opencode.jsonc" : "opencode.json";
|
|
27315
|
-
|
|
27320
|
+
const entryAsString = (entry) => {
|
|
27321
|
+
if (typeof entry === "string")
|
|
27322
|
+
return entry;
|
|
27323
|
+
if (Array.isArray(entry) && typeof entry[0] === "string")
|
|
27324
|
+
return entry[0];
|
|
27325
|
+
return null;
|
|
27326
|
+
};
|
|
27327
|
+
if (existingIdx >= 0 && rawPlugins[existingIdx] === PLUGIN_ENTRY_WITH_VERSION2) {
|
|
27316
27328
|
pass(`Plugin registered in ${configName}`);
|
|
27317
27329
|
} else if (existingIdx >= 0) {
|
|
27318
|
-
const oldEntry =
|
|
27319
|
-
|
|
27320
|
-
|
|
27330
|
+
const oldEntry = rawPlugins[existingIdx];
|
|
27331
|
+
const oldEntryStr = entryAsString(oldEntry) ?? "";
|
|
27332
|
+
if (isDevPathPluginEntry(oldEntry)) {
|
|
27333
|
+
pass(`Plugin registered in ${configName} (dev path: ${oldEntryStr})`);
|
|
27321
27334
|
} else {
|
|
27322
|
-
const isPinned =
|
|
27335
|
+
const isPinned = oldEntryStr !== PLUGIN_NAME6 && oldEntryStr !== PLUGIN_ENTRY_WITH_VERSION2 && /^@cortexkit\/opencode-magic-context@\d/.test(oldEntryStr);
|
|
27323
27336
|
if (isPinned && !options.force) {
|
|
27324
|
-
warn(`Plugin pinned to ${
|
|
27337
|
+
warn(`Plugin pinned to ${oldEntryStr} in ${configName} — use 'doctor --force' to upgrade`);
|
|
27325
27338
|
} else {
|
|
27326
|
-
|
|
27327
|
-
|
|
27339
|
+
if (Array.isArray(oldEntry) && oldEntry.length >= 1) {
|
|
27340
|
+
const replacement = [...oldEntry];
|
|
27341
|
+
replacement[0] = PLUGIN_ENTRY_WITH_VERSION2;
|
|
27342
|
+
rawPlugins[existingIdx] = replacement;
|
|
27343
|
+
} else {
|
|
27344
|
+
rawPlugins[existingIdx] = PLUGIN_ENTRY_WITH_VERSION2;
|
|
27345
|
+
}
|
|
27346
|
+
config2.plugin = rawPlugins;
|
|
27328
27347
|
writeFileSync9(paths.opencodeConfig, `${import_comment_json7.stringify(config2, null, 2)}
|
|
27329
27348
|
`);
|
|
27330
|
-
pass(`Upgraded plugin entry in ${configName}: ${
|
|
27349
|
+
pass(`Upgraded plugin entry in ${configName}: ${oldEntryStr} → ${PLUGIN_ENTRY_WITH_VERSION2}`);
|
|
27331
27350
|
fixed++;
|
|
27332
27351
|
}
|
|
27333
27352
|
}
|
|
27334
27353
|
} else {
|
|
27335
|
-
|
|
27336
|
-
config2.plugin =
|
|
27354
|
+
rawPlugins.push(PLUGIN_ENTRY_WITH_VERSION2);
|
|
27355
|
+
config2.plugin = rawPlugins;
|
|
27337
27356
|
writeFileSync9(paths.opencodeConfig, `${import_comment_json7.stringify(config2, null, 2)}
|
|
27338
27357
|
`);
|
|
27339
27358
|
pass(`Added plugin to ${configName}`);
|
|
@@ -27369,22 +27388,40 @@ async function runDoctor(options = {}) {
|
|
|
27369
27388
|
try {
|
|
27370
27389
|
const tuiRaw = readFileSync11(paths.tuiConfig, "utf-8");
|
|
27371
27390
|
const tuiConfig = import_comment_json7.parse(tuiRaw);
|
|
27372
|
-
const
|
|
27373
|
-
const tuiIdx =
|
|
27391
|
+
const tuiRawPlugins = Array.isArray(tuiConfig?.plugin) ? tuiConfig.plugin : [];
|
|
27392
|
+
const tuiIdx = tuiRawPlugins.findIndex((entry) => matchesPluginEntry(entry, PLUGIN_NAME6) || isDevPathPluginEntry(entry));
|
|
27393
|
+
const tuiEntryAsString = (entry) => {
|
|
27394
|
+
if (typeof entry === "string")
|
|
27395
|
+
return entry;
|
|
27396
|
+
if (Array.isArray(entry) && typeof entry[0] === "string")
|
|
27397
|
+
return entry[0];
|
|
27398
|
+
return "";
|
|
27399
|
+
};
|
|
27374
27400
|
if (tuiIdx >= 0) {
|
|
27375
|
-
const tuiEntry =
|
|
27376
|
-
const
|
|
27377
|
-
if (
|
|
27378
|
-
|
|
27379
|
-
} else if (tuiPinned && options.force) {
|
|
27380
|
-
tuiPlugins[tuiIdx] = PLUGIN_ENTRY_WITH_VERSION2;
|
|
27381
|
-
tuiConfig.plugin = tuiPlugins;
|
|
27382
|
-
writeFileSync9(paths.tuiConfig, `${import_comment_json7.stringify(tuiConfig, null, 2)}
|
|
27383
|
-
`);
|
|
27384
|
-
pass(`Upgraded TUI plugin: ${tuiEntry} → ${PLUGIN_ENTRY_WITH_VERSION2}`);
|
|
27385
|
-
fixed++;
|
|
27401
|
+
const tuiEntry = tuiRawPlugins[tuiIdx];
|
|
27402
|
+
const tuiEntryStr = tuiEntryAsString(tuiEntry);
|
|
27403
|
+
if (isDevPathPluginEntry(tuiEntry)) {
|
|
27404
|
+
pass(`TUI sidebar plugin configured (dev path: ${tuiEntryStr})`);
|
|
27386
27405
|
} else {
|
|
27387
|
-
|
|
27406
|
+
const tuiPinned = tuiEntryStr !== PLUGIN_NAME6 && tuiEntryStr !== PLUGIN_ENTRY_WITH_VERSION2 && /^@cortexkit\/opencode-magic-context@\d/.test(tuiEntryStr);
|
|
27407
|
+
if (tuiPinned && !options.force) {
|
|
27408
|
+
warn(`TUI plugin pinned to ${tuiEntryStr} — use 'doctor --force' to upgrade`);
|
|
27409
|
+
} else if (tuiPinned && options.force) {
|
|
27410
|
+
if (Array.isArray(tuiEntry) && tuiEntry.length >= 1) {
|
|
27411
|
+
const replacement = [...tuiEntry];
|
|
27412
|
+
replacement[0] = PLUGIN_ENTRY_WITH_VERSION2;
|
|
27413
|
+
tuiRawPlugins[tuiIdx] = replacement;
|
|
27414
|
+
} else {
|
|
27415
|
+
tuiRawPlugins[tuiIdx] = PLUGIN_ENTRY_WITH_VERSION2;
|
|
27416
|
+
}
|
|
27417
|
+
tuiConfig.plugin = tuiRawPlugins;
|
|
27418
|
+
writeFileSync9(paths.tuiConfig, `${import_comment_json7.stringify(tuiConfig, null, 2)}
|
|
27419
|
+
`);
|
|
27420
|
+
pass(`Upgraded TUI plugin: ${tuiEntryStr} → ${PLUGIN_ENTRY_WITH_VERSION2}`);
|
|
27421
|
+
fixed++;
|
|
27422
|
+
} else {
|
|
27423
|
+
pass("TUI sidebar plugin configured");
|
|
27424
|
+
}
|
|
27388
27425
|
}
|
|
27389
27426
|
} else {
|
|
27390
27427
|
pass("TUI sidebar plugin configured");
|
|
@@ -27571,6 +27608,7 @@ var init_doctor_opencode = __esm(async () => {
|
|
|
27571
27608
|
init_conflict_fixer();
|
|
27572
27609
|
init_data_path();
|
|
27573
27610
|
init_tui_config();
|
|
27611
|
+
init_opencode();
|
|
27574
27612
|
init_diagnostics_opencode();
|
|
27575
27613
|
init_logs_opencode();
|
|
27576
27614
|
init_opencode_helpers();
|
|
@@ -161699,7 +161737,12 @@ async function runHealthChecks(options) {
|
|
|
161699
161737
|
} else {
|
|
161700
161738
|
add(results, "pass", `Embedding provider: ${loadedConfig.config.embedding.provider}`);
|
|
161701
161739
|
}
|
|
161702
|
-
|
|
161740
|
+
const piEntries = packages.filter((entry) => hasPiPackage([entry]));
|
|
161741
|
+
if (piEntries.length > 1) {
|
|
161742
|
+
add(results, "fail", `Multiple magic-context entries in Pi packages[] — this loads the plugin twice: ${piEntries.join(", ")}`);
|
|
161743
|
+
} else {
|
|
161744
|
+
add(results, "pass", "No conflicting magic-context entries in Pi packages[]");
|
|
161745
|
+
}
|
|
161703
161746
|
const otherExtensions = packages.filter((entry) => !hasPiPackage([entry]));
|
|
161704
161747
|
if (otherExtensions.length > 0) {
|
|
161705
161748
|
add(results, "info", `Other Pi extensions registered: ${otherExtensions.join(", ")}`);
|