npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

koishi-plugin-opencode

v1.0.5

Published

koishi opencode plugin

Downloads

1,320

Readme

Koishi 插件:OpenCode

简体中文 | English

一个将 OpenCode AI 能力集成到 Koishi 聊天机器人的插件。

安装

普通用户

在 Koishi 控制台的插件商店中直接搜索安装:

  1. 打开 Koishi 控制台
  2. 进入插件市场
  3. 搜索 opencode
  4. 点击安装

开发者

克隆仓库并在本地开发:

git clone https://github.com/DoiiarX/koishi-plugin-opencode.git
cd koishi-plugin-opencode
npm install

配置

在 Koishi 配置文件中添加插件:

plugins:
  opencode:
    # OpenCode 服务器地址
    baseUrl: "http://localhost:4096"
    # 默认会话 ID(可选)
    defaultSession: ""
    # 覆盖默认模型(格式:provider/model)
    model: ""
    # 生成超时时间(毫秒,默认 30000)
    timeout: 30000
    # 命令所需权限等级(默认 1)
    authority: 1

✨ 核心特性

  • 🤖 智能多模态:支持文本对话,更支持通过标准 Koishi 标签(<img src="...">, <audio>, <video>, <file>)直接发送媒体文件(参考 Koishi 元素文档)。
  • 🔄 会话自动恢复:基于 Title(Koishi-<platform>-<userId>)自动锚定历史会话,服务重启不丢失上下文。
  • 🌊 智能流式输出:支持原生编辑 (editMessage) 和分段发送两种模式,打字机效果更流畅,且具备 HTML 标签完整性保护。
  • 🛠️ 强大的插件系统:支持接入各类基于 OpenCode 协议的工具与 Agent。
  • 🔍 深度推理展示:支持显示思维链 (Chain of Thought),让 AI 的思考过程透明化。

配置选项

| 配置项 | 类型 | 默认值 | 说明 | | :--- | :--- | :--- | :--- | | baseUrl | string | http://localhost:4096 | OpenCode Server 的地址 | | defaultSession | string | - | 默认会话 ID (通常保留为空以使用自动管理) | | model | string | - | 指定使用的模型 (格式: provider/model) | | timeout | number | 30000 | 消息生成超时时间(毫秒) | | authority | number | 1 | 命令所需权限等级 | | showReasoning | boolean | true | 是否显示 <think> 推理过程 | | enableStreaming | boolean | true | 是否开启流式输出 | | streamMode | auto | native | segment | auto | 流式输出模式 (native: 原生编辑, segment: 分段发送) | | streamInterval | number | 500 | 流式更新间隔(毫秒) | | showToolMessages | boolean | true | 是否显示工具调用消息 | | showProcessingMessage | boolean | true | 是否显示 "🔄 正在处理" 提示 | | directory | string | - | 默认工作区目录 |

命令

基础命令

发送消息

oc [消息]

向 OpenCode 发送消息并获取回复。支持直接输入文本作为参数。

示例:

oc 法国的首都是哪里?

检查健康状态

oc.health
oc.h

检查 OpenCode 服务器的健康状态。

示例:

oc.h

模型管理

列出模型

oc.models [关键词]
oc.m [关键词]

列出所有可用模型。可选择性按关键词过滤。

示例:

oc.models claude

设置默认模型

oc.model.set <模型>
oc.ms <模型>

为所有对话设置默认模型。

示例:

oc.ms anthropic/claude-3-5-sonnet-20241022

会话管理

列出会话

oc.session.list
oc.sl

列出所有可用会话。

创建新会话

oc.session.new
oc.sn

为当前用户创建新会话(如果您想强制通过新的上下文开始对话)。

切换会话

oc.session.set <id>
oc.ss <id>

切换到指定会话。

查看会话信息

oc.session.info
oc.si

查看当前会话的信息。

删除会话

oc.session.delete <id>
oc.sdel <id>

删除指定会话。

查看历史消息

oc.session.messages [页码]

分页查看当前会话的历史用户消息。

其他

列出 Agents

oc.agents

列出 OpenCode 服务器上所有可用的 Agent 工具。

查看流式状态

oc.stream.status

查看当前会话的流式输出配置和适配器支持情况。

权限等级

不同命令有不同的默认权限等级:

| 命令组 | 权限等级 | |---------------|-----------------| | 基础对话 | 1 | | 查看会话信息 | 1 | | 查看历史消息 | 1 | | 列出模型 | 1 | | 列出 Agents | 1 | | 查看流式状态 | 1 | | 切换会话 | 2 | | 设置模型 | 3 | | 列出会话 | 3 | | 创建会话 | 1 | | 删除会话 | 4 |

系统要求

  • Koishi v4.18.7 或更高版本
  • OpenCode 服务器正在运行并可访问

平台支持

本项目利用 Koishi 强大的适配器系统,实现多平台 OpenCode 交互。Koishi 通过官方和第三方适配器支持广泛的聊天平台:

官方支持的平台

  • 钉钉
  • Discord
  • KOOK
  • 飞书
  • LINE
  • 邮件
  • Matrix
  • QQ
  • Slack
  • Telegram
  • 微信公众号
  • 企业微信
  • WhatsApp
  • Zulip

多平台集成能力

  • 预装适配器:常用适配器已预装在 Koishi 中,可在插件配置的 adapter 分组中找到
  • 多账号支持:单个 Koishi 应用可同时接入多个平台的多个账号
  • 负载均衡:同一平台内接入的多个机器人共享用户数据,方便实现负载均衡
  • 可扩展性:除了官方适配器,插件市场中还有大量第三方聊天平台适配器

Koishi 生态优势

基于 Koishi 构建,本项目享有:

  • 丰富的插件生态:接入数千个插件,功能可无限扩展
  • 高级权限管理:细粒度的权限控制,为不同命令设置不同的权限等级
  • 生命周期管理:完善的插件初始化和生命周期钩子机制
  • 配置管理:集中化、灵活的配置系统
  • 长期社区维护:Koishi 是一个成熟、活跃维护的聊天机器人框架,拥有强大的社区支持

平台准备工作

不同平台的接入方式和难度存在较大差异,可能需要:

  • 在平台内注册开发者账号
  • 准备一台部署到公网的服务器
  • 配置 API 密钥

详细的平台接入指南可在各个适配器插件的文档中找到。

好消息是:Koishi 的大部分功能都不依赖特定的聊天平台。在进行准备工作的同时,你完全可以阅读本文档的后续部分,并在沙盒中体验并学习插件的功能。

快速开始

  1. 安装 OpenCode 服务器:安装指南
  2. 启动 OpenCode 服务器
  3. 在 Koishi 中安装此插件
  4. 配置 baseUrl 指向你的 OpenCode 服务器
  5. 重启 Koishi

许可证

MIT

链接