opencode-tbot 0.1.19 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md CHANGED
@@ -6,20 +6,26 @@
6
6
 
7
7
  > このプロジェクトは OpenCode チームによって開発されたものではなく、公式な関連もありません。
8
8
 
9
- ## できること
9
+ ## 概要
10
10
 
11
11
  `opencode-tbot` を使うと、Telegram から OpenCode を操作できます。
12
12
 
13
13
  - テキストメッセージは現在アクティブな OpenCode セッションに転送されます。
14
- - Telegram の画像は OpenCode のファイルパートとしてアップロードされます。
15
- - Telegram の音声メッセージは、通常の prompt フローに入る前に OpenRouter で文字起こしできます。
16
- - OpenCode が発行した権限リクエストは、Telegram のインラインボタンから直接承認または拒否できます。
14
+ - Telegram の写真と画像ドキュメントは OpenCode のファイルパートとしてアップロードされます。
15
+ - Telegram の音声メッセージは明示的に拒否され、ローカライズされた返信を返します。
16
+ - OpenCode が発行した権限リクエストは、Telegram のインラインボタンから承認または拒否できます。
17
17
  - セッション完了やエラーイベントは、紐付けられた Telegram チャットへ通知できます。
18
- - チャット状態は JSON の state ファイルに保存され、Node と Bun の両方のランタイムで動作します。
18
+ - チャットの紐付け状態は JSON の state ファイルに保存されます。
19
+
20
+ ## 前提条件
21
+
22
+ - このプラグインを読み込む OpenCode ホストプロセスが動作していること。
23
+ - Telegram bot token を用意していること。
24
+ - CLI とローカル開発には Node.js `>=22.12.0` が必要です。
19
25
 
20
26
  ## インストール
21
27
 
22
- 次を実行します。
28
+ 推奨インストール方法:
23
29
 
24
30
  ```bash
25
31
  npm exec --package opencode-tbot@latest opencode-tbot -- install
@@ -39,11 +45,20 @@ OpenCode に登録済みの npm プラグイン spec を更新:
39
45
  npm exec --package opencode-tbot@latest opencode-tbot -- update
40
46
  ```
41
47
 
42
- OpenCode 上でプラグインが `file:///.../node_modules/...` のようなパスで表示される場合は、古いローカル npm インストールを削除します。
48
+ ### CLI オプション
43
49
 
44
- ```bash
45
- npm uninstall opencode-tbot
46
- ```
50
+ `install` で利用可能:
51
+
52
+ - `--bot-token <token>` Telegram bot token を非対話で設定
53
+ - `--telegram-api-root <url>` Telegram Bot API のベース URL を上書き
54
+ - `--plugin-spec <spec>` カスタム npm プラグイン spec を登録
55
+ - `--skip-register` OpenCode 側のプラグイン登録は変更せず、プラグイン設定だけを書き換え
56
+ - `--home-dir <path>` カスタム home ディレクトリを使用
57
+
58
+ `update` で利用可能:
59
+
60
+ - `--plugin-spec <spec>`
61
+ - `--home-dir <path>`
47
62
 
48
63
  ## 設定
49
64
 
@@ -52,7 +67,11 @@ npm uninstall opencode-tbot
52
67
  1. `~/.config/opencode/opencode-tbot/config.json` のグローバルデフォルト
53
68
  2. `<worktree>/tbot.config.json` のプロジェクト上書き設定
54
69
 
55
- プロジェクト設定はグローバル設定に上書きマージされます。`telegram`、`state`、`openrouter` はセクション単位でディープマージされます。
70
+ プロジェクト設定はグローバル設定に上書きマージされます。`telegram` と `state` はセクション単位でディープマージされます。
71
+
72
+ 古い `openrouter` 音声転写設定はランタイムでは無視され、インストーラーが設定を書き直す際にも削除されます。
73
+
74
+ リポジトリには最小構成の参考として [tbot.config.example.json](./tbot.config.example.json) も含まれています。
56
75
 
57
76
  ### `tbot.config.json` の例
58
77
 
@@ -66,12 +85,6 @@ npm uninstall opencode-tbot
66
85
  "state": {
67
86
  "path": "./data/opencode-tbot.state.json"
68
87
  },
69
- "openrouter": {
70
- "apiKey": "your_openrouter_api_key",
71
- "model": "openai/gpt-audio-mini",
72
- "timeoutMs": 30000,
73
- "transcriptionPrompt": ""
74
- },
75
88
  "logLevel": "info"
76
89
  }
77
90
  ```
@@ -84,39 +97,27 @@ npm uninstall opencode-tbot
84
97
  | `telegram.allowedChatIds` | いいえ | `[]` | 許可する Telegram chat ID の配列。空の場合はすべての chat を受け付けます。 |
85
98
  | `telegram.apiRoot` | いいえ | `https://api.telegram.org` | Telegram Bot API のベース URL。テストやセルフホストのゲートウェイ向けです。 |
86
99
  | `state.path` | いいえ | `./data/opencode-tbot.state.json` | JSON state ファイルのパス。現在の OpenCode worktree からの相対パスとして解決されます。 |
87
- | `openrouter.apiKey` | いいえ | `""` | OpenRouter API key。音声文字起こしを有効にする場合のみ必要です。 |
88
- | `openrouter.model` | いいえ | `openai/gpt-audio-mini` | 音声文字起こしに使う OpenRouter モデル。 |
89
- | `openrouter.timeoutMs` | いいえ | `30000` | 音声文字起こしのタイムアウト時間(ミリ秒)。 |
90
- | `openrouter.transcriptionPrompt` | いいえ | `""` | 文字起こしプロンプトに追加される任意の補足指示。 |
91
100
  | `logLevel` | いいえ | `info` | プラグインのログレベル。ログは `client.app.log()` 経由で出力されます。 |
92
101
 
93
- ## ランタイム上の前提
94
-
95
- 必須:
96
-
97
- - `telegram.botToken`
102
+ ### 補足
98
103
 
99
- 任意:
100
-
101
- - `telegram.allowedChatIds`
102
- - `telegram.apiRoot`
103
- - `state.path`
104
- - `openrouter.apiKey`
105
- - `openrouter.model`
106
- - `openrouter.timeoutMs`
107
- - `openrouter.transcriptionPrompt`
108
- - `logLevel`
104
+ - `state.path` は現在の OpenCode worktree からの相対パスとして解決されます。
105
+ - `telegram.allowedChatIds` を空のままにすると、bot は任意の chat からのメッセージを受け付けます。本番では制限を設定してください。
106
+ - 権限承認とセッション通知はプラグインの hook で処理されます。
107
+ - `/language` は現在 English、简体中文、日本語 をサポートしています。
109
108
 
110
- 補足:
109
+ ## クイックスタート
111
110
 
112
- - `state.path` のデフォルトは `./data/opencode-tbot.state.json` で、現在の OpenCode worktree からの相対パスとして解決されます。
113
- - ログは `client.app.log()` 経由で出力されます。
114
- - 権限承認とセッション通知はプラグインの hook で処理されます。
111
+ 1. `npm exec --package opencode-tbot@latest opencode-tbot -- install` でプラグインをインストールします。
112
+ 2. 特定の chat のみ許可したい場合は、`tbot.config.json` で `telegram.allowedChatIds` を設定します。
113
+ 3. 対象の worktree で OpenCode を起動し、プラグインランタイムを読み込ませます。
114
+ 4. Telegram で `/status` を実行し、接続を確認します。
115
+ 5. `/new [title]` を実行するか、テキストメッセージを直接送信して使い始めます。
115
116
 
116
117
  ## コマンド
117
118
 
118
119
  - `/start` 短いウェルカムメッセージとクイックスタート手順を表示
119
- - `/status` OpenCode のヘルス、パス、LSP、MCP の状態をまとめて表示
120
+ - `/status` OpenCode のヘルス、パス、プラグイン、LSP、MCP の状態をまとめて表示
120
121
  - `/new [title]` 新しい OpenCode セッションを作成
121
122
  - `/agents` または `/agent` 利用可能な agent を一覧表示し、アクティブな agent を切り替え
122
123
  - `/sessions` 利用可能なセッションを一覧表示し、アクティブなセッションを切り替え
@@ -124,7 +125,11 @@ npm uninstall opencode-tbot
124
125
  - `/model` または `/models` 利用可能なモデルを一覧表示し、アクティブなモデルを切り替え
125
126
  - `/language` bot の表示言語を切り替え
126
127
 
127
- コマンド以外のテキストメッセージは prompt として扱われ、OpenCode に送信されます。OpenRouter が設定されている場合、Telegram の `voice` メッセージは文字起こし後に同じ prompt フローへ入ります。Telegram の画像は OpenCode のファイルパートとして転送されます。
128
+ メッセージ処理:
129
+
130
+ - コマンド以外のテキストは prompt として扱われ、OpenCode に送信されます。
131
+ - Telegram の写真と画像ドキュメントは OpenCode のファイルパートとして転送されます。
132
+ - Telegram の音声メッセージは未対応で、ローカライズされた拒否メッセージを返します。
128
133
 
129
134
  ## 開発
130
135
 
package/README.md CHANGED
@@ -2,24 +2,30 @@
2
2
 
3
3
  A Telegram plugin for driving [OpenCode](https://opencode.ai) from chat.
4
4
 
5
- [English](./README.md) | [简体中文](./README.zh-CN.md)
5
+ [English](./README.md) | [简体中文](./README.zh-CN.md) | [日本語](./README.ja.md)
6
6
 
7
7
  > This project is not built by the OpenCode team and is not affiliated with them.
8
8
 
9
- ## What It Does
9
+ ## Overview
10
10
 
11
11
  `opencode-tbot` lets you operate OpenCode from Telegram.
12
12
 
13
13
  - Text messages are forwarded to the active OpenCode session.
14
- - Telegram images are uploaded as OpenCode file parts.
15
- - Telegram voice messages are explicitly rejected with a localized error reply.
16
- - Permission requests raised by OpenCode can be approved or rejected directly from Telegram inline buttons.
14
+ - Telegram photos and image documents are uploaded as OpenCode file parts.
15
+ - Telegram voice messages are explicitly rejected with a localized reply.
16
+ - Permission requests raised by OpenCode can be approved or rejected from Telegram inline buttons.
17
17
  - Session completion and error events can be reported back to the bound Telegram chat.
18
- - Chat state is stored in a JSON state file that works in both Node and Bun runtimes.
18
+ - Chat bindings are stored in a JSON state file.
19
+
20
+ ## Requirements
21
+
22
+ - A running OpenCode host process that loads the plugin.
23
+ - A Telegram bot token.
24
+ - Node.js `>=22.12.0` for the CLI and local development workflow.
19
25
 
20
26
  ## Install
21
27
 
22
- Run:
28
+ Recommended install:
23
29
 
24
30
  ```bash
25
31
  npm exec --package opencode-tbot@latest opencode-tbot -- install
@@ -39,23 +45,34 @@ Update the registered npm plugin spec in OpenCode:
39
45
  npm exec --package opencode-tbot@latest opencode-tbot -- update
40
46
  ```
41
47
 
42
- Remove a legacy local npm install if OpenCode is showing the plugin as a `file:///.../node_modules/...` path:
48
+ ### CLI Options
43
49
 
44
- ```bash
45
- npm uninstall opencode-tbot
46
- ```
50
+ `install` supports:
51
+
52
+ - `--bot-token <token>` set the Telegram bot token non-interactively
53
+ - `--telegram-api-root <url>` override the Telegram Bot API root
54
+ - `--plugin-spec <spec>` register a custom npm plugin spec
55
+ - `--skip-register` only rewrite plugin config without touching OpenCode plugin registration
56
+ - `--home-dir <path>` use a custom home directory
57
+
58
+ `update` supports:
59
+
60
+ - `--plugin-spec <spec>`
61
+ - `--home-dir <path>`
47
62
 
48
63
  ## Configuration
49
64
 
50
- The runtime config is loaded in this order:
65
+ Runtime config is loaded in this order:
51
66
 
52
- 1. global defaults from `~/.config/opencode/opencode-tbot/config.json`
53
- 2. project overrides from `<worktree>/tbot.config.json`
67
+ 1. Global defaults from `~/.config/opencode/opencode-tbot/config.json`
68
+ 2. Project overrides from `<worktree>/tbot.config.json`
54
69
 
55
70
  Project config is merged on top of the global config. `telegram` and `state` are deep-merged by section.
56
71
 
57
72
  Legacy `openrouter` voice-transcription settings are ignored at runtime. When the installer rewrites the config, it removes them.
58
73
 
74
+ The repository also includes [tbot.config.example.json](./tbot.config.example.json) as a minimal reference.
75
+
59
76
  ### Example `tbot.config.json`
60
77
 
61
78
  ```json
@@ -82,29 +99,25 @@ Legacy `openrouter` voice-transcription settings are ignored at runtime. When th
82
99
  | `state.path` | No | `./data/opencode-tbot.state.json` | JSON state file path, resolved relative to the current OpenCode worktree. |
83
100
  | `logLevel` | No | `info` | Plugin log level. Logs are emitted through `client.app.log()`. |
84
101
 
85
- ## Runtime Expectations
86
-
87
- Required:
88
-
89
- - `telegram.botToken`
90
-
91
- Optional:
102
+ ### Notes
92
103
 
93
- - `telegram.allowedChatIds`
94
- - `telegram.apiRoot`
95
- - `state.path`
96
- - `logLevel`
104
+ - `state.path` is resolved relative to the current OpenCode worktree.
105
+ - If `telegram.allowedChatIds` is left empty, the bot accepts messages from any chat. Restrict it in production.
106
+ - Permission approvals and session notifications are handled through plugin hooks.
107
+ - `/language` currently supports English, Simplified Chinese, and Japanese.
97
108
 
98
- Notes:
109
+ ## Quick Start
99
110
 
100
- - `state.path` defaults to `./data/opencode-tbot.state.json` and is resolved relative to the current OpenCode worktree.
101
- - Logs are emitted through `client.app.log()`.
102
- - Permission approvals and session notifications are handled through plugin hooks.
111
+ 1. Install the plugin with `npm exec --package opencode-tbot@latest opencode-tbot -- install`.
112
+ 2. Set `telegram.allowedChatIds` in `tbot.config.json` if you want to restrict the bot to specific chats.
113
+ 3. Start OpenCode in the target worktree so the plugin runtime can load.
114
+ 4. In Telegram, run `/status` to verify the connection.
115
+ 5. Run `/new [title]` or send a text message directly to start working.
103
116
 
104
117
  ## Commands
105
118
 
106
119
  - `/start` show a short welcome message and quick-start steps
107
- - `/status` show aggregated OpenCode health, path, LSP, and MCP status
120
+ - `/status` show aggregated OpenCode health, path, plugin, LSP, and MCP status
108
121
  - `/new [title]` create a new OpenCode session
109
122
  - `/agents` or `/agent` list available agents and switch the active one
110
123
  - `/sessions` list available sessions and switch the active one
@@ -112,7 +125,11 @@ Notes:
112
125
  - `/model` or `/models` list available models and switch the active one
113
126
  - `/language` switch the bot display language
114
127
 
115
- Any non-command text message is treated as a prompt and sent to OpenCode. Telegram images are forwarded as OpenCode file parts. Telegram voice messages are not supported and receive a localized rejection reply.
128
+ Message handling:
129
+
130
+ - Non-command text is treated as a prompt and sent to OpenCode.
131
+ - Telegram photos and image documents are forwarded as OpenCode file parts.
132
+ - Telegram voice messages are not supported and receive a localized rejection reply.
116
133
 
117
134
  ## Development
118
135
 
package/README.zh-CN.md CHANGED
@@ -2,24 +2,30 @@
2
2
 
3
3
  一个通过 Telegram 驱动 [OpenCode](https://opencode.ai) 的插件。
4
4
 
5
- [English](./README.md) | [简体中文](./README.zh-CN.md)
5
+ [English](./README.md) | [简体中文](./README.zh-CN.md) | [日本語](./README.ja.md)
6
6
 
7
7
  > 本项目并非由 OpenCode 团队开发,也不隶属于 OpenCode 官方。
8
8
 
9
- ## 项目说明
9
+ ## 项目概览
10
10
 
11
11
  `opencode-tbot` 允许你直接在 Telegram 中操作 OpenCode。
12
12
 
13
- - 文本消息会转发到当前 OpenCode 会话。
14
- - Telegram 图片会作为 OpenCode 文件片段上传。
13
+ - 文本消息会转发到当前激活的 OpenCode 会话。
14
+ - Telegram 照片和图片文档会作为 OpenCode 文件片段上传。
15
15
  - Telegram 语音消息会被明确拒绝,并返回本地化提示。
16
16
  - OpenCode 触发的权限请求可以直接在 Telegram 内联按钮中批准或拒绝。
17
- - 会话完成和错误事件可以主动回推到绑定的 Telegram chat。
18
- - 聊天状态通过 JSON 状态文件持久化,可兼容 Node 和 Bun 运行环境。
17
+ - 会话完成和错误事件可以回推到绑定的 Telegram chat。
18
+ - 聊天绑定状态通过 JSON 状态文件持久化。
19
+
20
+ ## 环境要求
21
+
22
+ - 一个正在运行、并会加载该插件的 OpenCode Host 进程。
23
+ - 一个 Telegram bot token。
24
+ - Node.js `>=22.12.0`,用于 CLI 和本地开发流程。
19
25
 
20
26
  ## 安装
21
27
 
22
- 执行:
28
+ 推荐安装方式:
23
29
 
24
30
  ```bash
25
31
  npm exec --package opencode-tbot@latest opencode-tbot -- install
@@ -39,11 +45,20 @@ npm exec --package opencode-tbot@latest opencode-tbot -- --version
39
45
  npm exec --package opencode-tbot@latest opencode-tbot -- update
40
46
  ```
41
47
 
42
- 如果 OpenCode 把插件显示成 `file:///.../node_modules/...` 路径,可删除旧的本地 npm 安装:
48
+ ### CLI 参数
43
49
 
44
- ```bash
45
- npm uninstall opencode-tbot
46
- ```
50
+ `install` 支持:
51
+
52
+ - `--bot-token <token>` 非交互式写入 Telegram bot token
53
+ - `--telegram-api-root <url>` 覆盖 Telegram Bot API 根地址
54
+ - `--plugin-spec <spec>` 注册自定义 npm 插件 spec
55
+ - `--skip-register` 只重写插件配置,不改动 OpenCode 的插件注册
56
+ - `--home-dir <path>` 使用自定义 home 目录
57
+
58
+ `update` 支持:
59
+
60
+ - `--plugin-spec <spec>`
61
+ - `--home-dir <path>`
47
62
 
48
63
  ## 配置
49
64
 
@@ -54,7 +69,9 @@ npm uninstall opencode-tbot
54
69
 
55
70
  项目配置会覆盖全局默认值;`telegram` 和 `state` 会按分段进行深合并。
56
71
 
57
- 遗留的 `openrouter` 语音转写配置在运行时会被忽略;安装器重写配置时会自动清理这些字段。
72
+ 遗留的 `openrouter` 语音转写配置在运行时会被忽略;安装器重写配置时也会自动移除这些字段。
73
+
74
+ 仓库内还提供了 [tbot.config.example.json](./tbot.config.example.json) 作为最小配置参考。
58
75
 
59
76
  ### `tbot.config.json` 示例
60
77
 
@@ -82,29 +99,25 @@ npm uninstall opencode-tbot
82
99
  | `state.path` | 否 | `./data/opencode-tbot.state.json` | JSON 状态文件路径,相对当前 OpenCode worktree 解析。 |
83
100
  | `logLevel` | 否 | `info` | 插件日志级别。日志统一通过 `client.app.log()` 上报。 |
84
101
 
85
- ## 运行时约定
86
-
87
- 必填:
102
+ ### 说明
88
103
 
89
- - `telegram.botToken`
104
+ - `state.path` 会相对当前 OpenCode worktree 解析。
105
+ - 如果 `telegram.allowedChatIds` 为空,bot 会接受任意 chat 的消息;生产环境建议显式限制。
106
+ - 权限审批和会话通知通过插件 hook 处理。
107
+ - `/language` 当前支持 English、简体中文、日本語。
90
108
 
91
- 可选:
109
+ ## 快速开始
92
110
 
93
- - `telegram.allowedChatIds`
94
- - `telegram.apiRoot`
95
- - `state.path`
96
- - `logLevel`
97
-
98
- 说明:
99
-
100
- - `state.path` 默认是 `./data/opencode-tbot.state.json`,并相对当前 OpenCode worktree 解析。
101
- - 日志通过 `client.app.log()` 统一输出。
102
- - 权限审批和会话通知由插件 hook 处理。
111
+ 1. 使用 `npm exec --package opencode-tbot@latest opencode-tbot -- install` 安装插件。
112
+ 2. 如果你只想允许特定聊天使用 bot,请在 `tbot.config.json` 中设置 `telegram.allowedChatIds`。
113
+ 3. 在目标 worktree 中启动 OpenCode,让插件运行时被加载。
114
+ 4. 在 Telegram 中执行 `/status` 验证连接是否正常。
115
+ 5. 执行 `/new [title]`,或者直接发送文本消息开始使用。
103
116
 
104
117
  ## 命令
105
118
 
106
119
  - `/start` 显示简短欢迎信息和快速开始说明
107
- - `/status` 显示 OpenCode 健康状态、路径、LSP 和 MCP 信息
120
+ - `/status` 显示 OpenCode 健康状态、路径、插件、LSP 和 MCP 信息
108
121
  - `/new [title]` 创建新的 OpenCode 会话
109
122
  - `/agents` 或 `/agent` 列出可用 agent 并切换当前 agent
110
123
  - `/sessions` 列出会话并切换当前会话
@@ -112,7 +125,11 @@ npm uninstall opencode-tbot
112
125
  - `/model` 或 `/models` 列出可用模型并切换当前模型
113
126
  - `/language` 切换 bot 显示语言
114
127
 
115
- 任意非命令文本都会被当作 prompt 发送给 OpenCode。图片会作为 OpenCode 文件片段上传。Telegram 语音消息当前不受支持,bot 会直接返回本地化拒绝提示。
128
+ 消息处理规则:
129
+
130
+ - 任意非命令文本都会被当作 prompt 发送给 OpenCode。
131
+ - Telegram 照片和图片文档会作为 OpenCode 文件片段上传。
132
+ - Telegram 语音消息当前不受支持,bot 会直接返回本地化拒绝提示。
116
133
 
117
134
  ## 开发
118
135
 
@@ -140,7 +157,7 @@ pnpm test
140
157
 
141
158
  ### 我需要一个正在运行的 OpenCode 实例吗?
142
159
 
143
- 需要。这一仓库提供的是 Telegram 集成层,依赖加载它的 OpenCode Host 进程。
160
+ 需要。这个仓库提供的是 Telegram 集成层,依赖加载它的 OpenCode Host 进程。
144
161
 
145
162
  ### 这是 OpenCode 官方项目吗?
146
163