Skip to content

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

@darrenhinde

Description

@darrenhinde

Installing @opencode-ai/plugin@^0.9.11 cannot import the tool helper reliably.

import { tool } from "@opencode-ai/plugin" may raise TS2305, and import { tool } from "@opencode-ai/plugin/tool" may raise TS2307, depending on the TS resolver.
This blocks defining custom tools in .opencode/tool/*.ts.

Impact
Custom tools fail to typecheck/compile in external repos.
Friction adopting Opencode plugin tooling.

Reproduction

  1. Fresh repo
  2. bun add @opencode-ai/plugin@^0.9.11
  3. Create .opencode/tool/foo.ts:

import { tool } from "@opencode-ai/plugin/"

Proposed fix (repo: packages/plugin)
Update packages/plugin/package.json:

{
  "name": "@opencode-ai/plugin",
  "version": "0.9.12",
  "type": "module",
  "main": "./dist/index.js",
  "types": "./dist/index.d.ts",
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.js",
      "default": "./dist/index.js"
    },
    "./tool": {
      "types": "./dist/tool.d.ts",
      "import": "./dist/tool.js",
      "default": "./dist/tool.js"
    }
  },
  "files": ["dist"],
  "scripts": {
    "build": "tsc -p tsconfig.json",
    "prepublishOnly": "bun run build"
  }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions