Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions bin/cli/commands/setup-open-code.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const PACKAGE_ROOT = resolve(__dirname, "..", "..", "..");
// (see root package.json `files`: ["@omniroute/", ...]). The env override
// exists so tests can point at a fixture without building the real plugin.
const BUNDLED_PLUGIN_DIR =
process.env.OMNIROUTE_OPENCODE_PLUGIN_DIR ||
join(PACKAGE_ROOT, "@omniroute", "opencode-plugin");
process.env.OMNIROUTE_OPENCODE_PLUGIN_DIR || join(PACKAGE_ROOT, "@omniroute", "opencode-plugin");

/**
* Resolve the OpenCode config directory. Honours XDG_CONFIG_HOME and the
Expand Down Expand Up @@ -89,7 +88,7 @@ function resolveOpenCodeDirs() {
* a clear error instead of running tsup here, because the CLI runtime
* may not have tsup available (it's a devDependency).
*
* @returns {{ distEntry: string, cjsEntry: string, packageDir: string }}
* @returns {{ distEntry: string, packageDir: string }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The JSDoc description above (specifically on line 84 of the file) still mentions dist/index.cjs (e.g., Built (dist/index.cjs + dist/index.js exist)). Since the CommonJS bundle has been dropped, please update that description to reflect that only dist/index.js is expected.

*/
function resolveBundledPlugin() {
if (!existsSync(BUNDLED_PLUGIN_DIR)) {
Expand All @@ -102,17 +101,17 @@ function resolveBundledPlugin() {
}

const esmEntry = join(BUNDLED_PLUGIN_DIR, "dist", "index.js");
const cjsEntry = join(BUNDLED_PLUGIN_DIR, "dist", "index.cjs");

if (!existsSync(esmEntry) || !existsSync(cjsEntry)) {
if (!existsSync(esmEntry)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the Repository Style Guide (Rule 9), you must always include or update tests when changing production code under bin/. Since bin/cli/commands/setup-open-code.mjs has been modified, please ensure that corresponding test changes or additions are included in this pull request.

References
  1. Always include tests when changing production code (src/, open-sse/, electron/, bin/). (link)

throw new Error(
`@omniroute/opencode-plugin dist/ not built (looked for ${esmEntry}).\n` +
`Run \`cd ${BUNDLED_PLUGIN_DIR} && npm install && npm run build\` and re-run this command.`
);
}

// Prefer ESM. OpenCode (≥1.15) loads ESM modules natively.
return { distEntry: esmEntry, cjsEntry, packageDir: BUNDLED_PLUGIN_DIR };
// ESM-only build (CJS was dropped in tsup config). OpenCode (>=1.15) loads
// ESM modules natively.
return { distEntry: esmEntry, packageDir: BUNDLED_PLUGIN_DIR };
}

/**
Expand Down