跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    中文English
    emilsvennesson

    Websearch

    v0.6.0模型接入
    opencode-websearch

    Web search plugin for OpenCode

    GitHub 星标

    50

    近 30 天 +2

    月装机量

    3,946

    近 7 天 2.3k

    综合评分SCORE

    53.3

    生态多维模型

    最近提交

    3 个月前

    2026-05-07

    快速安装与配置

    opencode.json

    写入当前项目的 opencode.json,只对这个仓库生效。

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-websearch@0.6.0"]
    }

    opencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。

    Native web search for OpenCode, powered by your model's built-in search capability. No extra API keys or search services required. If you're on a supported provider, it works without any extra setup.

    Inspired by Claude Code's WebSearch tool.

    Example

    Asking OpenCode about the latest PostgreSQL version:

    What's the latest Postgres version?

    web-search [query=latest PostgreSQL release version April 2026]

    As of now (April 2026), the latest PostgreSQL community release is PostgreSQL 18.3.
    If you mean the latest major version line, that is PostgreSQL 18.

    Sources:

    Supported providers

    Provider What you need
    Anthropic An Anthropic provider/model in OpenCode with built-in web search support
    Moonshot (Kimi) A Moonshot API key configured in OpenCode
    OpenAI / ChatGPT OpenAI configured in OpenCode (API key or ChatGPT connected)
    GitHub Copilot GitHub Copilot connected in OpenCode

    Model-level web search support depends on the provider and model you use.

    Install

    Add the plugin to your opencode.json and OpenCode will install it automatically on startup.

    {
      "plugin": ["opencode-websearch"]
    }
    

    Configuration (optional)

    By default the plugin uses your active model. The optional "websearch" flag lets you pin or provide a fallback model for search:

    • "always": always use this model for web search
    • "auto": use this model as fallback when your active provider is not supported

    Selection order

    1. A model tagged "websearch": "always"
    2. Your active model (if on a supported provider)
    3. A model tagged "websearch": "auto"
    4. Otherwise, the tool returns an error

    Example

    {
      "provider": {
        "openai": {
          "models": {
            "gpt-5.2": {
              "options": {
                "websearch": "always"
              }
            }
          }
        }
      }
    }
    

    Development

    Local development

    Clone the repo and symlink the source entry into your OpenCode plugin directory:

    git clone https://github.com/emilsvennesson/opencode-websearch ~/.config/opencode/opencode-websearch
    cd ~/.config/opencode/opencode-websearch
    bun install
    mkdir -p ~/.config/opencode/plugin
    ln -sf ~/.config/opencode/opencode-websearch/src/index.ts ~/.config/opencode/plugin/websearch.ts
    

    OpenCode loads the plugin directly from source at startup.

    When using this symlink setup, remove "opencode-websearch" from the plugin array in opencode.json to avoid loading it twice.

    Commands

    bun install
    bun run format
    bun run format:check
    bun run lint
    bun run lint:fix
    bun run typecheck
    bun run check
    bun run build
    

    License

    MIT