Skip to content

Commit 6220313

Browse files
committed
fix: include src/shared in npm package for TUI, add @latest to plugin entries
- Added src/shared to package.json files so TUI parent imports resolve - Plugin entries now written as @cortexkit/opencode-magic-context@latest - Reverted conflict-fixer to zero npm deps (readJsoncFile + JSON.stringify) so TUI process can import it without comment-json
1 parent 94c4019 commit 6220313

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

packages/plugin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"files": [
2929
"dist",
3030
"src/tui",
31+
"src/shared",
3132
"README.md"
3233
],
3334
"scripts": {

packages/plugin/src/cli/doctor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { isOpenCodeInstalled } from "./opencode-helpers";
88
import { intro, log, outro } from "./prompts";
99

1010
const PLUGIN_NAME = "@cortexkit/opencode-magic-context";
11+
const PLUGIN_ENTRY_WITH_VERSION = `${PLUGIN_NAME}@latest`;
1112

1213
export async function runDoctor(): Promise<number> {
1314
intro("Magic Context Doctor");
@@ -60,7 +61,7 @@ export async function runDoctor(): Promise<number> {
6061
log.success(`Plugin registered in ${configName}`);
6162
} else {
6263
// Auto-add plugin entry — preserves comments
63-
const updatedPlugins = [...(plugins as unknown[]), PLUGIN_NAME];
64+
const updatedPlugins = [...(plugins as unknown[]), PLUGIN_ENTRY_WITH_VERSION];
6465
config.plugin = updatedPlugins;
6566
writeFileSync(paths.opencodeConfig, `${stringify(config, null, 2)}\n`);
6667
log.success(`Added plugin to ${configName}`);

packages/plugin/src/cli/setup.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import { confirm, intro, log, note, outro, selectOne, spinner } from "./prompts";
1414

1515
const PLUGIN_NAME = "@cortexkit/opencode-magic-context";
16+
const PLUGIN_ENTRY = "@cortexkit/opencode-magic-context@latest";
1617

1718
// ─── Helpers ──────────────────────────────────────────────
1819

@@ -38,7 +39,7 @@ function addPluginToOpenCodeConfig(configPath: string, format: "json" | "jsonc"
3839

3940
if (format === "none") {
4041
const config = {
41-
plugin: [PLUGIN_NAME],
42+
plugin: [PLUGIN_ENTRY],
4243
compaction: { auto: false, prune: false },
4344
};
4445
writeFileSync(configPath, `${stringifyJsonc(config, null, 2)}\n`);
@@ -56,7 +57,7 @@ function addPluginToOpenCodeConfig(configPath: string, format: "json" | "jsonc"
5657
const plugins = (existing.plugin as string[]) ?? [];
5758
const hasPlugin = plugins.some((p) => p === PLUGIN_NAME || p.startsWith(`${PLUGIN_NAME}@`));
5859
if (!hasPlugin) {
59-
plugins.push(PLUGIN_NAME);
60+
plugins.push(PLUGIN_ENTRY);
6061
}
6162
existing.plugin = plugins;
6263

@@ -73,7 +74,7 @@ function addPluginToTuiConfig(configPath: string, format: "json" | "jsonc" | "no
7374
ensureDir(dirname(configPath));
7475

7576
if (format === "none") {
76-
writeFileSync(configPath, `${stringifyJsonc({ plugin: [PLUGIN_NAME] }, null, 2)}\n`);
77+
writeFileSync(configPath, `${stringifyJsonc({ plugin: [PLUGIN_ENTRY] }, null, 2)}\n`);
7778
return;
7879
}
7980

@@ -86,7 +87,7 @@ function addPluginToTuiConfig(configPath: string, format: "json" | "jsonc" | "no
8687
const plugins = (existing.plugin as string[]) ?? [];
8788
const hasPlugin = plugins.some((p) => p === PLUGIN_NAME || p.startsWith(`${PLUGIN_NAME}@`));
8889
if (!hasPlugin) {
89-
plugins.push(PLUGIN_NAME);
90+
plugins.push(PLUGIN_ENTRY);
9091
}
9192

9293
existing.plugin = plugins;

packages/plugin/src/shared/tui-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { log } from "./logger";
1010
import { getOpenCodeConfigPaths } from "./opencode-config-dir";
1111

1212
const PLUGIN_NAME = "@cortexkit/opencode-magic-context";
13+
const PLUGIN_ENTRY = `${PLUGIN_NAME}@latest`;
1314

1415
function resolveTuiConfigPath(): string {
1516
const configDir = getOpenCodeConfigPaths({ binary: "opencode" }).configDir;
@@ -43,7 +44,7 @@ export function ensureTuiPluginEntry(): boolean {
4344
return false; // Already present
4445
}
4546

46-
plugins.push(PLUGIN_NAME);
47+
plugins.push(PLUGIN_ENTRY);
4748
config.plugin = plugins;
4849

4950
mkdirSync(dirname(configPath), { recursive: true });

0 commit comments

Comments
 (0)