[PR #2680] fix(plugin): add missing types to package.json exports for tool imports #10407

Closed
opened 2026-02-16 18:15:03 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/2680

State: closed
Merged: No


Problem

Fixes #2678 - Cannot import tool helper from @opencode-ai/plugin in external repos

Installing @opencode-ai/plugin@^0.9.11 causes TypeScript import errors:

  • import { tool } from "@opencode-ai/plugin" → TS2305 (no exported member)
  • import { tool } from "@opencode-ai/plugin/tool" → TS2307 (cannot find module)

This blocks defining custom tools in .opencode/tool/*.ts files.

Root Cause

Package.json exports field was missing explicit "types" mappings for both root and subpath imports, preventing TypeScript from resolving .d.ts files.

Solution

  • Add top-level main and types fields for legacy compatibility
  • Add "types" to both . and "./tool" exports pointing to existing declaration files
  • No functional changes, only improves TypeScript module resolution

Verification

After this fix, consumers can reliably import:

import { tool } from "@opencode-ai/plugin"       
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/2680 **State:** closed **Merged:** No --- ## Problem Fixes #2678 - Cannot import tool helper from @opencode-ai/plugin in external repos Installing `@opencode-ai/plugin@^0.9.11` causes TypeScript import errors: - `import { tool } from "@opencode-ai/plugin"` → TS2305 (no exported member) - `import { tool } from "@opencode-ai/plugin/tool"` → TS2307 (cannot find module) This blocks defining custom tools in `.opencode/tool/*.ts` files. ## Root Cause Package.json `exports` field was missing explicit `"types"` mappings for both root and subpath imports, preventing TypeScript from resolving `.d.ts` files. ## Solution - Add top-level `main` and `types` fields for legacy compatibility - Add `"types"` to both `.` and `"./tool"` exports pointing to existing declaration files - No functional changes, only improves TypeScript module resolution ## Verification After this fix, consumers can reliably import: ```ts import { tool } from "@opencode-ai/plugin" ```
yindo added the pull-request label 2026-02-16 18:15:03 -05:00
yindo closed this issue 2026-02-16 18:15:03 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10407