JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 466
  • Score
    100M100P100Q112988F
  • License MIT

Node.js-native Feishu/Lark bridge for OpenCode — production-grade daemon, persistence, preflight, structured logs.

Package Exports

  • @neomei/opencode-feishu
  • @neomei/opencode-feishu/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@neomei/opencode-feishu) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

OpenCode 飞书集成插件

将 OpenCode AI 助手接入飞书(Feishu/Lark),支持私聊和群聊,提供流式输出和工具状态通知。

安装

npm install -g @neomei/opencode-feishu

快速开始

1. 配置插件

opencode-feishu setup

按向导输入 App ID、App Secret 等配置。

2. 启动插件

# 启动(需要 OpenCode 服务器运行)
opencode-feishu start

# 指定配置文件
opencode-feishu start -c /path/to/config.json

3. 管理插件

# 查看状态
opencode-feishu status

# 停止插件
opencode-feishu stop

飞书应用配置

创建应用

  1. 访问 飞书开放平台
  2. 创建"企业自建应用"
  3. 开启"机器人"能力
  4. 添加权限:
    • im:message
    • im:message.p2p_msg:readonly
    • im:message.group_at_msg:readonly
    • im:message:send_as_bot
    • im:resource
    • contact:user.base:readonly
  5. 事件配置:使用长连接,添加 im.message.receive_v1
  6. 发布应用

获取凭证

在"凭证与基础信息"页面获取 App ID(格式:cli_xxxxxxxx)和 App Secret

配置项

配置文件位置:~/.config/opencode/feishu.json

{
  "appId": "cli_xxxxxxxx",
  "appSecret": "xxxxxxxx",
  "domain": "feishu",
  "opencodeUrl": "http://localhost:19876",
  "streaming": true,
  "requireMention": true,
  "groupPolicy": "allowlist",
  "allowlist": []
}
配置项 说明 默认值
appId 飞书 App ID -
appSecret 飞书 App Secret -
domain 域名:feishulark feishu
opencodeUrl OpenCode 服务器地址 http://localhost:19876
streaming 启用流式输出 true
requireMention 群聊需@机器人 true
groupPolicy 群策略:open/allowlist/disabled allowlist
allowlist 用户白名单 []

appSecret 也可通过环境变量 FEISHU_APP_SECRET 设置,优先级高于配置文件。

使用方式

私聊

直接发送消息给机器人即可开始对话。

群聊

在群中 @机器人 发送消息(需开启 requireMention)。

连续会话

每个聊天(私聊/群聊)对应一个独立的 OpenCode session,支持上下文连续对话。

特性

  • 流式输出:OpenCode 的回复实时显示在飞书中
  • 状态通知:显示思考中、工具执行等状态
  • 自动重连:WebSocket 断线后 SDK 自动重连
  • 双模式运行
    • 独立模式opencode-feishu start
    • 插件模式:在 OpenCode 中加载

CLI 命令

opencode-feishu setup    # 配置向导
opencode-feishu start    # 启动插件
opencode-feishu status   # 查看状态
opencode-feishu stop     # 停止插件
opencode-feishu --help   # 查看帮助

作为 OpenCode 插件使用

在 OpenCode 配置中添加:

{
  "plugins": ["@neomei/opencode-feishu"]
}

环境要求

  • Node.js >= 18.0.0
  • OpenCode 服务器运行中
  • 飞书企业自建应用

许可证

MIT