{"id":51181617,"url":"https://github.com/neomei/opencode-feishu","last_synced_at":"2026-06-27T07:03:33.197Z","repository":{"id":353196966,"uuid":"1218358147","full_name":"NeoMei/opencode-feishu","owner":"NeoMei","description":"OpenCode Feishu/Lark integration plugin — AI assistant bridge with streaming output, tool status, and multi-profile support","archived":false,"fork":false,"pushed_at":"2026-06-19T19:00:56.000Z","size":178,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-19T20:13:28.875Z","etag":null,"topics":["agentsoul","ai-bot","chatbot","feishu","lark","nodejs","opencode"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@neomei/opencode-feishu","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NeoMei.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-22T19:48:24.000Z","updated_at":"2026-06-19T19:00:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/NeoMei/opencode-feishu","commit_stats":null,"previous_names":["neomei/opencode-feishu"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/NeoMei/opencode-feishu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeoMei%2Fopencode-feishu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeoMei%2Fopencode-feishu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeoMei%2Fopencode-feishu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeoMei%2Fopencode-feishu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NeoMei","download_url":"https://codeload.github.com/NeoMei/opencode-feishu/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeoMei%2Fopencode-feishu/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34844350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-27T02:00:06.362Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agentsoul","ai-bot","chatbot","feishu","lark","nodejs","opencode"],"created_at":"2026-06-27T07:03:32.138Z","updated_at":"2026-06-27T07:03:33.188Z","avatar_url":"https://github.com/NeoMei.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenCode 飞书集成插件\n\n将 OpenCode AI 助手接入飞书（Feishu/Lark），支持私聊和群聊，提供流式输出和工具状态通知。\n\n## 安装\n\n```bash\nnpm install -g @neomei/opencode-feishu\n```\n\n## 快速开始\n\n### 1. 配置插件\n\n```bash\nopencode-feishu setup\n```\n\n**默认扫码配置（推荐）**：运行后会显示二维码，使用飞书 App 扫码即可自动创建应用并获取凭证，无需手动输入。\n\n**手动配置**：如果扫码失败，会自动切换到手动输入模式。\n\n### 2. 启动插件\n\n```bash\n# 前台启动（需要 OpenCode 服务器运行）\nopencode-feishu start\n\n# 后台守护进程启动\nopencode-feishu start --daemon\n\n# 指定配置文件\nopencode-feishu start -c /path/to/config.json\n```\n\n### 3. 管理插件\n\n```bash\n# 查看状态\nopencode-feishu status\n\n# 停止插件\nopencode-feishu stop\n```\n\n## 飞书应用配置\n\n### 创建应用\n\n1. 访问 [飞书开放平台](https://open.feishu.cn/app)\n2. 创建\"企业自建应用\"\n3. 开启\"机器人\"能力\n4. 添加权限：\n   - `im:message`\n   - `im:message.p2p_msg:readonly`\n   - `im:message.group_at_msg:readonly`\n   - `im:message:send_as_bot`\n   - `im:resource`\n   - `contact:user.base:readonly`\n5. 事件配置：使用长连接，添加 `im.message.receive_v1`\n6. 发布应用\n\n### 获取凭证\n\n在\"凭证与基础信息\"页面获取 **App ID**（格式：`cli_xxxxxxxx`）和 **App Secret**。\n\n## 配置项\n\n配置文件位置：`~/.config/opencode/feishu.json`\n\n```json\n{\n  \"appId\": \"cli_xxxxxxxx\",\n  \"appSecret\": \"xxxxxxxx\",\n  \"domain\": \"feishu\",\n  \"opencodeUrl\": \"http://localhost:19876\",\n  \"streaming\": true,\n  \"requireMention\": true,\n  \"groupPolicy\": \"allowlist\",\n  \"allowlist\": []\n}\n```\n\n| 配置项 | 说明 | 默认值 |\n|--------|------|--------|\n| `appId` | 飞书 App ID | - |\n| `appSecret` | 飞书 App Secret | - |\n| `domain` | 域名：`feishu` 或 `lark` | `feishu` |\n| `opencodeUrl` | OpenCode 服务器地址 | `http://localhost:19876` |\n| `streaming` | 启用流式输出 | `true` |\n| `requireMention` | 群聊需@机器人 | `true` |\n| `groupPolicy` | 群策略：`open`/`allowlist`/`disabled` | `allowlist` |\n| `allowlist` | 用户白名单 | `[]` |\n\n\u003e `appSecret` 也可通过环境变量 `FEISHU_APP_SECRET` 设置，优先级高于配置文件。\n\n## 使用方式\n\n### 私聊\n直接发送消息给机器人即可开始对话。\n\n### 群聊\n在群中 @机器人 发送消息（需开启 `requireMention`）。\n\n### 连续会话\n每个聊天（私聊/群聊）对应一个独立的 OpenCode session，支持上下文连续对话。\n\n## 特性\n\n- **流式输出**：OpenCode 的回复实时显示在飞书中\n- **状态通知**：显示思考中、工具执行等状态\n- **自动重连**：WebSocket 断线后 SDK 自动重连\n- **双模式运行**：\n  - **独立模式**：`opencode-feishu start`\n  - **插件模式**：在 OpenCode 中加载\n- **多配置管理**：支持多个飞书应用配置快速切换（profile）\n- **权限预检**：`doctor` 命令自动检查 API 权限\n- **服务层 API**：提供完整的飞书 API 封装（IM、文档、日历、任务、审批等）\n\n## CLI 命令\n\n```bash\nopencode-feishu setup              # 配置向导\nopencode-feishu start              # 启动插件\nopencode-feishu status             # 查看状态\nopencode-feishu stop               # 停止插件\nopencode-feishu doctor             # 运行预检（检查配置、凭证、权限）\nopencode-feishu logs               # 查看日志\nopencode-feishu --help             # 查看帮助\n\n# 多配置管理（Profile）\nopencode-feishu profile list       # 列出所有配置\nopencode-feishu profile add prod   # 从当前配置创建 profile\nopencode-feishu profile use prod   # 切换到指定 profile\nopencode-feishu profile show       # 显示当前配置\n```\n\n## 服务层 API\n\n除了 CLI 工具，本插件还提供了完整的飞书 API 服务层，可在代码中直接使用：\n\n```typescript\nimport { FeishuAPI, DocService, CalendarService, TaskService, ApprovalService } from '@neomei/opencode-feishu';\n\nconst api = new FeishuAPI({ appId: 'cli_xxx', appSecret: 'xxx', domain: 'feishu' });\nawait api.initialize();\n\n// 文档操作\nconst docService = new DocService(api);\n\n// 创建文档\nconst doc = await docService.createDocumentFromMarkdown('项目计划', '# 目标\\n\\n- 完成API设计\\n- 编写文档');\n\n// 读取文档\nconst content = await docService.fetchDocument(doc.documentId, {\n  detail: 'simple',\n  docFormat: 'markdown'\n});\n\n// 更新文档\nawait docService.updateDocument(doc.documentId, 'append', {\n  content: '\u003cp\u003e新增段落\u003c/p\u003e'\n});\n\n// 搜索文档\nconst results = await docService.searchDocuments('项目计划');\n\n// 分享文档到群聊\nawait docService.shareDocument('chat-123', doc.documentId, {\n  description: '请查看项目计划'\n});\n\n// 日历操作\nconst calendarService = new CalendarService(api);\nconst calendars = await calendarService.listCalendars();\nconst events = await calendarService.listEvents('primary', {\n  startTime: '2024-01-01T00:00:00Z',\n  endTime: '2024-01-31T23:59:59Z',\n});\n\n// 任务管理\nconst taskService = new TaskService(api);\nconst task = await taskService.createTask({\n  summary: '完成项目文档',\n  dueTime: '2024-01-15T18:00:00Z',\n});\n\n// 审批查询\nconst approvalService = new ApprovalService(api);\nconst instances = await approvalService.listInstances({ status: 'pending' });\n```\n\n### 支持的服务\n\n| 服务 | 功能 |\n|------|------|\n| `IMService` | 消息发送、富文本、文档卡片、回复、搜索、下载 |\n| `DocService` | 文档创建(XML/Markdown)、读取(支持局部/大纲)、更新(8种指令)、搜索、分享 |\n| `ChatService` | 群组搜索、成员管理 |\n| `ContactService` | 用户搜索、部门查询 |\n| `CalendarService` | 日历、日程 CRUD、忙闲查询 |\n| `TaskService` | 任务创建、更新、完成、删除 |\n| `ApprovalService` | 审批查询、批准、拒绝、转交 |\n\n## 作为 OpenCode 插件使用\n\n在 OpenCode 配置中添加：\n\n```json\n{\n  \"plugins\": [\"@neomei/opencode-feishu\"]\n}\n```\n\n## 与 AgentSoul 配合使用\n\n搭配 [@neomei/agentsoul](https://github.com/NeoMei/agentsoul) 可为飞书机器人注入人格和长期记忆：\n\n```bash\n# 1. 安装两个插件\nnpm install -g @neomei/agentsoul @neomei/opencode-feishu\n\n# 2. 配置 AgentSoul 人格\nagentsoul setup\n\n# 3. 配置飞书连接\nopencode-feishu setup\n\n# 4. 在 opencode.json 中同时注册两个插件\n```\n\n```json\n{\n  \"plugin\": [\n    \"@neomei/agentsoul\",\n    \"@neomei/opencode-feishu\"\n  ]\n}\n```\n\n启动 OpenCode serve 后，飞书用户的对话会自动触发 AgentSoul 的 soul 注入和记忆保存。\n\n## 环境要求\n\n- Node.js \u003e= 18.0.0\n- OpenCode 服务器运行中\n- 飞书企业自建应用\n\n## 许可证\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneomei%2Fopencode-feishu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneomei%2Fopencode-feishu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneomei%2Fopencode-feishu/lists"}