diff --git a/README.md b/README.md index 168b4b1..06a39b1 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ orgx-opencode-plugin Or programmatic: ```ts -import { startPeer } from '@useorgx/orgx-opencode-plugin'; +import { startPeer } from '@useorgx/orgx-opencode-plugin/sdk'; const peer = await startPeer({ apiKey: process.env.ORGX_API_KEY!, diff --git a/package-lock.json b/package-lock.json index 50ec16e..e672679 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@useorgx/orgx-opencode-plugin", - "version": "0.1.0-alpha.11", + "version": "0.1.0-alpha.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@useorgx/orgx-opencode-plugin", - "version": "0.1.0-alpha.11", + "version": "0.1.0-alpha.12", "license": "MIT", "dependencies": { "@opencode-ai/sdk": "^1.18.2", diff --git a/package.json b/package.json index f20ea2d..9ad7141 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@useorgx/orgx-opencode-plugin", - "version": "0.1.0-alpha.11", + "version": "0.1.0-alpha.12", "publishConfig": { "access": "public" }, @@ -17,6 +17,10 @@ ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" + }, + "./sdk": { + "types": "./dist/sdk.d.ts", + "import": "./dist/sdk.js" } }, "files": [ diff --git a/plugin.manifest.json b/plugin.manifest.json index 9a5849b..12d4438 100644 --- a/plugin.manifest.json +++ b/plugin.manifest.json @@ -1,6 +1,6 @@ { "plugin_name": "@useorgx/orgx-opencode-plugin", - "version": "0.1.0-alpha.11", + "version": "0.1.0-alpha.12", "manifest_fingerprint": "", "signature": "", "capabilities": [ diff --git a/src/index.ts b/src/index.ts index 5efb062..bf446b5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,21 +1,3 @@ -export { OpenCodeDriver, type OpenCodeDriverOptions } from './OpenCodeDriver.js'; -export { - default, - createOrgXOpenCodePlugin, - OrgXOpenCodePlugin, - type CreateOrgXOpenCodePluginOptions, -} from './plugin.js'; -export type { StartedPeer, StartPeerOptions } from './peer.js'; -export { - buildWorkGraphEventRecord, - recordWorkGraphEvent, - resolveWorkGraphOutboxPath, -} from './workGraphOutbox.js'; -export { inspectOpenCodeV2Canary } from './v2Canary.js'; - -export async function startPeer( - opts: import('./peer.js').StartPeerOptions -): Promise { - const peer = await import('./peer.js'); - return peer.startPeer(opts); -} +// OpenCode invokes every package-root export as a plugin factory. Keep this +// entry point deliberately closed-world; library helpers live at ./sdk. +export { OrgXOpenCodePlugin } from './plugin.js'; diff --git a/src/peer.ts b/src/peer.ts index f62a212..efbaf1c 100644 --- a/src/peer.ts +++ b/src/peer.ts @@ -4,7 +4,7 @@ * * Usage (CLI or programmatic): * - * import { startPeer } from '@useorgx/orgx-opencode-plugin'; + * import { startPeer } from '@useorgx/orgx-opencode-plugin/sdk'; * await startPeer({ * apiKey: process.env.ORGX_API_KEY, * workspaceId: process.env.ORGX_WORKSPACE_ID, diff --git a/src/plugin.test.ts b/src/plugin.test.ts index 14dea99..70e368b 100644 --- a/src/plugin.test.ts +++ b/src/plugin.test.ts @@ -125,11 +125,18 @@ describe('OrgXOpenCodePlugin', () => { ); }); - it('loads the package entry without eagerly importing the peer runtime', async () => { + it('exposes exactly one callable plugin from the package root', async () => { const mod = await import('./index'); - expect(typeof mod.default).toBe('function'); + expect(Object.keys(mod)).toEqual(['OrgXOpenCodePlugin']); expect(typeof mod.OrgXOpenCodePlugin).toBe('function'); + }); + + it('keeps peer and driver helpers on the explicit SDK entry', async () => { + const mod = await import('./sdk'); + + expect(typeof mod.OrgXOpenCodePlugin).toBe('function'); + expect(typeof mod.OpenCodeDriver).toBe('function'); expect(typeof mod.startPeer).toBe('function'); }); diff --git a/src/sdk.ts b/src/sdk.ts new file mode 100644 index 0000000..ba56623 --- /dev/null +++ b/src/sdk.ts @@ -0,0 +1,20 @@ +export { OpenCodeDriver, type OpenCodeDriverOptions } from './OpenCodeDriver.js'; +export { + createOrgXOpenCodePlugin, + OrgXOpenCodePlugin, + type CreateOrgXOpenCodePluginOptions, +} from './plugin.js'; +export type { StartedPeer, StartPeerOptions } from './peer.js'; +export { + buildWorkGraphEventRecord, + recordWorkGraphEvent, + resolveWorkGraphOutboxPath, +} from './workGraphOutbox.js'; +export { inspectOpenCodeV2Canary } from './v2Canary.js'; + +export async function startPeer( + opts: import('./peer.js').StartPeerOptions +): Promise { + const peer = await import('./peer.js'); + return peer.startPeer(opts); +}