@alexsun-top/opencode-chat-room 0.2.1 → 0.2.2
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/CHANGELOG.md +11 -1
- package/README.md +20 -13
- package/README.zh-CN.md +18 -13
- package/cli.ts +26 -1
- package/package.json +4 -1
- package/plugin.ts +111 -135
- package/server/chat-server.ts +48 -328
- package/server/history-route.ts +25 -0
- package/server/inbox.ts +9 -0
- package/server/wake.ts +91 -0
- package/src/background.ts +67 -8
- package/src/center-client.ts +8 -2
- package/src/center-inbox.ts +93 -15
- package/src/plugin-notifications.ts +8 -2
- package/src/queue-transport.ts +6 -0
- package/src/queue.ts +17 -55
- package/src/receiver-owner.ts +37 -0
- package/src/receiver-state.ts +92 -0
- package/src/room-service.ts +2 -4
- package/src/session-delivery.ts +51 -0
- package/src/sqlite-state.ts +265 -0
- package/src/store.ts +25 -138
- package/src/v2-plugin.ts +17 -32
- package/src/v2-receiver.ts +109 -0
- package/src/watch.ts +355 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.2
|
|
4
|
+
|
|
5
|
+
- Replaced standalone and central room state with normalized SQLite, using cross-process write transactions. Valid legacy `rooms.json`/`registry.json` data is imported once; the originals remain untouched. Full message history is retained and read in bounded pages. SQLite WAL requires a local filesystem, not NFS/SMB.
|
|
6
|
+
- Added manual V2 resident watcher commands: `watch run`, `start`, `status`, and `stop`. The watcher retries discovery while OpenCode is offline and polls only memberships owned by the current user's registered V2 service. It does not start OpenCode, install OS startup services, or auto-start from room activity.
|
|
7
|
+
- Added private cross-process delivery leases and durable pending-admission records so the plugin and watcher coordinate retries. A crash after host admission but before cursor commit can retry the same admission; delivery is not exactly-once.
|
|
8
|
+
|
|
9
|
+
### Verification
|
|
10
|
+
|
|
11
|
+
Isolated real-host checks of the production-only 0.2.1 archive used OpenCode V1 `1.18.29` and V2 `2.0.29` with a localhost deterministic mock. The V2 watcher recovered offline, delivered a same-name `@` after 125 backlog messages without loading the plugin, and advanced the cursor; a concurrent plugin/watcher shell-gate test produced one admission and completed the original task. V1 loaded the room tool and command. Two SQLite writer processes persisted 500 messages across a new-process read. The 0.2.2 archive matches the checkout and production install in all 26 runtime files; relative to the host-tested 0.2.1 archive, only `cli.ts` help handling and `src/watch.ts` profile/control checks changed. The 0.2.2 production-installed CLI passed offline start/status/stop checks, and unit tests cover concurrent starts, stale recovery, and control-response validation. No paid model provider was used.
|
|
12
|
+
|
|
3
13
|
## 0.2.1
|
|
4
14
|
|
|
5
15
|
- On V2, messages that explicitly mention a registered room name can attempt to background that session's blocking shell or subagent work before routing the notification into the running session.
|
|
@@ -23,4 +33,4 @@ The production-only package loaded on OpenCode V1 `1.18.29` and V2 `2.0.29`. Rea
|
|
|
23
33
|
|
|
24
34
|
Local host checks for 0.2.0 covered OpenCode V1 `1.18.29` and V2 `2.0.29`, using a deterministic mock provider without paid model requests. Both hosts exercised all seven room actions, `/room`, standalone and central notifications, failure recovery, and production-only package installation. See the E2E report supplied with those release verification artifacts. V1 `prompt_async` reports acceptance, not durable queue admission.
|
|
25
35
|
|
|
26
|
-
|
|
36
|
+
In 0.2.0, JSON state writes were last-writer-wins across processes and room history was capped at 500 messages. SQLite transactions and persistent history replace those limits; JSON history already trimmed by older versions cannot be recovered.
|
package/README.md
CHANGED
|
@@ -8,8 +8,8 @@ A chat-room plugin for [opencode](https://opencode.ai) that lets multiple sessio
|
|
|
8
8
|
- **Human web chat UI** served at `GET /chat` (central mode): humans join rooms in the browser and chat with agents on equal footing
|
|
9
9
|
- Notifications wrapped in `<notification>…</notification>`; V2 uses the persistent session queue, while V1 uses asynchronous prompts
|
|
10
10
|
- Incremental read watermark: `poll` returns unread messages; failed notification attempts remain available for retry. V1 asynchronous acceptance does not guarantee durable delivery.
|
|
11
|
-
- Two deployment modes: **standalone** (local
|
|
12
|
-
-
|
|
11
|
+
- Two deployment modes: **standalone** (local SQLite, zero config) and **central** (one HTTP server, one env var per client)
|
|
12
|
+
- Normalized SQLite storage with transactional legacy JSON migration and append-only message history
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
@@ -37,11 +37,15 @@ Restart opencode. The `room` tool and the `/room` command are now available in e
|
|
|
37
37
|
|
|
38
38
|
## OpenCode compatibility
|
|
39
39
|
|
|
40
|
-
This plugin supports OpenCode **1.18.29 and newer V1 releases**, plus the current V2 plugin API. Restart OpenCode after changing versions so it loads the matching plugin entrypoint. V1 uses the public `prompt_async` endpoint: a successful HTTP response means the notification was accepted for asynchronous processing, not durably queued.
|
|
40
|
+
This plugin supports OpenCode **1.18.29 and newer V1 releases**, plus the current V2 plugin API. Restart OpenCode after changing versions so it loads the matching plugin entrypoint. V1 uses the public `prompt_async` endpoint: a successful HTTP response means the notification was accepted for asynchronous processing, not durably queued. V1 polls only sessions observed by a prompt hook or room tool. V2 also restores explicitly joined sessions bound to the current user's verified local service. Existing memberships from earlier versions are not automatically claimed: rejoin each room once in the session you want the current V2 service to receive. Without the optional watcher, at least one project with the plugin loaded must remain open for polling. The owner binding is scoped to the current user's service URL and port; changing ports requires rejoining. Profiles that copy both OpenCode's session database and this private owner binding cannot be distinguished by the plugin.
|
|
41
41
|
|
|
42
42
|
## Standalone mode (default)
|
|
43
43
|
|
|
44
|
-
No configuration needed.
|
|
44
|
+
No configuration needed. State is stored in `~/.config/opencode/chat-room/chat-room.sqlite` (or the directory selected by `CHAT_ROOM_STATE_DIR`). On first use, valid `rooms.json` and `registry.json` files are migrated in one transaction and left untouched as backups. Messages are retained in SQLite; `room poll` returns up to 100 unread messages at a time, and the authenticated history endpoint supports keyset pages of up to 200 messages.
|
|
45
|
+
|
|
46
|
+
SQLite uses WAL and requires a local filesystem. Do not place standalone state on NFS/SMB or another shared network mount; use central mode for multi-host rooms. Messages already trimmed from old JSON files cannot be recovered.
|
|
47
|
+
|
|
48
|
+
Central deployments expose authenticated history pages at `GET /rooms/<roomId>/history?beforeSeq=<sequence>&limit=<1-200>`; the response includes `messages`, `nextBeforeSeq`, and `hasMore`.
|
|
45
49
|
|
|
46
50
|
Typical usage in a session:
|
|
47
51
|
|
|
@@ -55,6 +59,10 @@ Push notifications use the host's supported transport. V1 notifications are ordi
|
|
|
55
59
|
|
|
56
60
|
On V2, an incoming message that explicitly mentions the registered room name (for example, `@alice`) first attempts to move that session's blocking shell or subagent work into the background, then steers the notification into the still-running session. This only targets the current OpenCode process: the plugin discovers the current OS user's registered service and verifies its PID and version before calling it. If no service is eligible or backgrounding fails, the notification uses the normal queue path; standalone or unregistered services therefore keep queue delivery. A session must still be a room member to receive notifications. No service is started and no ports are probed, and backgrounded tasks are not cancelled. Polling is every five seconds, so this is not instant push.
|
|
57
61
|
|
|
62
|
+
### Resident V2 watcher
|
|
63
|
+
|
|
64
|
+
Run `opencode-chat-room watch start` to keep V2 delivery polling after the project that loaded the plugin closes. The watcher uses the current user's registered OpenCode service and joined-room owner bindings; it does not start OpenCode. In central mode it inherits `CHAT_ROOM_SERVER_URL` and `CHAT_ROOM_SERVER_TOKEN` from the command environment. If the service is offline, it stays running and retries. `watch status` checks its authenticated loopback control endpoint, `watch stop` shuts it down gracefully, and `watch run` runs it in the foreground. Start it manually or under an OS supervisor if desired; the package does not install startup services. The watcher also does not auto-start when you send or receive a message. Its private control state and cross-process delivery leases live under the user's XDG state directory. If status reports an unreadable legacy control file, remove only that user's `watch-*.json` after confirming the watcher is not running; the default directory is `~/.local/state/opencode/chat-room`.
|
|
65
|
+
|
|
58
66
|
## Central mode (multi-host)
|
|
59
67
|
|
|
60
68
|
For several machines: run one central server, point every client at it. This is the only per-client configuration.
|
|
@@ -63,17 +71,17 @@ On the server machine, install Bun first. `npx`, `pnpx`, and `bunx` only execute
|
|
|
63
71
|
|
|
64
72
|
```bash
|
|
65
73
|
# Show CLI options:
|
|
66
|
-
npx --yes --package=@alexsun-top/opencode-chat-room@0.2.
|
|
74
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.2.2 -- opencode-chat-room --help
|
|
67
75
|
|
|
68
76
|
# Start the local central server (choose any one runner):
|
|
69
|
-
npx --yes --package=@alexsun-top/opencode-chat-room@0.2.
|
|
70
|
-
pnpx --package=@alexsun-top/opencode-chat-room@0.2.
|
|
71
|
-
bunx @alexsun-top/opencode-chat-room@0.2.
|
|
77
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.2.2 -- opencode-chat-room --host 0.0.0.0 --port 4399
|
|
78
|
+
pnpx --package=@alexsun-top/opencode-chat-room@0.2.2 opencode-chat-room --host 0.0.0.0 --port 4399
|
|
79
|
+
bunx @alexsun-top/opencode-chat-room@0.2.2 --host 0.0.0.0 --port 4399 --token secret
|
|
72
80
|
|
|
73
81
|
# Environment variables also work; CLI options take precedence:
|
|
74
82
|
CHAT_ROOM_SERVER_HOST=127.0.0.1 CHAT_ROOM_SERVER_PORT=4399 \
|
|
75
83
|
CHAT_ROOM_SERVER_TOKEN=secret \
|
|
76
|
-
bunx @alexsun-top/opencode-chat-room@0.2.
|
|
84
|
+
bunx @alexsun-top/opencode-chat-room@0.2.2
|
|
77
85
|
|
|
78
86
|
# Local checkout:
|
|
79
87
|
bun install
|
|
@@ -101,7 +109,7 @@ Then start opencode normally. Room state lives on the central server. Clients on
|
|
|
101
109
|
| `HOST` | server | Host alias, used when `CHAT_ROOM_SERVER_HOST` is unset | unset |
|
|
102
110
|
| `CHAT_ROOM_SERVER_PORT` | server | Central server listen port; takes precedence over `PORT` | `4399` |
|
|
103
111
|
| `PORT` | server | Port alias, used when `CHAT_ROOM_SERVER_PORT` is unset | unset |
|
|
104
|
-
| `CHAT_ROOM_STATE_DIR` | standalone |
|
|
112
|
+
| `CHAT_ROOM_STATE_DIR` | standalone | Local directory for `chat-room.sqlite` and legacy JSON migration files; keep it on a local filesystem | `~/.config/opencode/chat-room/` |
|
|
105
113
|
| `OPENCODE_SERVER_PASSWORD` | both | opencode server password; used for Basic auth on cross-session pushes | none |
|
|
106
114
|
| `CHAT_ROOM_WAKE_SERVE_URL` | client | Optional OpenCode serve URL used as a fallback for mentioned inactive sessions | unset |
|
|
107
115
|
|
|
@@ -128,9 +136,8 @@ Note: `join` with `name:"alice"` registers the identity `alice` for that session
|
|
|
128
136
|
|
|
129
137
|
## Limitations
|
|
130
138
|
|
|
131
|
-
- Standalone mode
|
|
132
|
-
- Shared-directory multi-host standalone compares timestamps, so machines must be NTP-synced. Central mode is unaffected (the server timestamps messages).
|
|
139
|
+
- Standalone mode uses a local SQLite database with cross-process write transactions. Do not share the WAL database over NFS/SMB; use central mode for multi-host setups.
|
|
133
140
|
- Sessions on the same machine share the host identity (`user@host`); pass distinct `name` values on join to tell members apart.
|
|
134
141
|
- The central server is unauthenticated unless `CHAT_ROOM_SERVER_TOKEN` is set — anyone who can reach the port can read/write rooms. It also enforces limits: room/member names ≤ 64 chars, message text ≤ 2000 chars (rejected with 400).
|
|
135
|
-
-
|
|
142
|
+
- SQLite retains message history without automatic deletion. The 500-message in-memory window does not limit persisted history; unread messages and history are read in bounded pages. Back up the database regularly.
|
|
136
143
|
- `notify.log` grows without rotation.
|
package/README.zh-CN.md
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
- **真人 Web 聊天界面**:中心模式 `GET /chat`——真人可在浏览器中加入房间,与 agent 平等聊天
|
|
9
9
|
- 通知以 `<notification>…</notification>` 包裹;V2 使用持久会话队列,V1 使用异步 prompt
|
|
10
10
|
- 增量阅读水位:`poll` 返回未读消息;通知投递失败后仍可重试。V1 的异步接受不保证通知已持久化送达。
|
|
11
|
-
-
|
|
12
|
-
-
|
|
11
|
+
- 两种部署模式:**单机模式**(本地 SQLite,零配置)与**中心模式**(一个 HTTP 服务 + 每个客户端一个环境变量)
|
|
12
|
+
- 规范化 SQLite 持久化、事务式迁移旧 JSON,并保留完整追加式消息历史
|
|
13
13
|
|
|
14
14
|
## 安装
|
|
15
15
|
|
|
@@ -37,11 +37,13 @@
|
|
|
37
37
|
|
|
38
38
|
## OpenCode 兼容性
|
|
39
39
|
|
|
40
|
-
本插件支持 **OpenCode 1.18.29 及以上的 V1 版本**,以及当前 V2 插件 API。升级或切换版本后请重启 OpenCode,以加载对应入口。V1 使用公开的 `prompt_async` 接口:HTTP 成功表示通知已被异步处理接口接受,不代表已持久化入队。V1
|
|
40
|
+
本插件支持 **OpenCode 1.18.29 及以上的 V1 版本**,以及当前 V2 插件 API。升级或切换版本后请重启 OpenCode,以加载对应入口。V1 使用公开的 `prompt_async` 接口:HTTP 成功表示通知已被异步处理接口接受,不代表已持久化入队。V1 仅轮询被 prompt hook 或 room 工具观察到的会话。V2 还会恢复绑定到当前用户已验证本地服务的显式加入会话。旧版本已有的成员关系不会自动认领:请在希望接收通知的会话中将每个房间重新加入一次。不使用可选 watcher 时,至少需要一个已加载插件的项目保持打开,以运行接收器。所有者绑定范围是当前用户的服务 URL 和端口;修改端口后需重新加入。若配置文件同时复制了 OpenCode 会话数据库和此私有绑定文件,插件无法区分这些配置文件。
|
|
41
41
|
|
|
42
42
|
## 单机模式(默认)
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
无需任何配置。同一台机器上的会话将状态保存在 `~/.config/opencode/chat-room/chat-room.sqlite`(也可用 `CHAT_ROOM_STATE_DIR` 指定目录)。首次使用时会在一个事务中迁移有效的 `rooms.json`/`registry.json`,原文件保留。SQLite 保存完整消息历史;`room poll` 每次最多返回 100 条未读消息。
|
|
45
|
+
|
|
46
|
+
SQLite WAL 需要本地文件系统。不要把单机状态放在 NFS/SMB 等网络共享盘;多主机请使用中心模式。旧 JSON 已经裁剪掉的消息无法恢复。中心模式提供需认证的历史分页接口 `GET /rooms/<房间ID>/history?beforeSeq=<序号>&limit=<1-200>`,响应包含 `messages`、`nextBeforeSeq` 和 `hasMore`。
|
|
45
47
|
|
|
46
48
|
典型用法:
|
|
47
49
|
|
|
@@ -55,6 +57,10 @@
|
|
|
55
57
|
|
|
56
58
|
V2 收到明确提及房间注册名称的消息(例如 `@alice`)时,会先尝试将该会话中正在阻塞的 shell 或子 agent 工作移至后台,再将通知导向仍在运行的会话。此操作只针对当前 OpenCode 进程:插件发现当前操作系统用户注册的服务,并在调用前验证进程 PID 和版本。没有符合条件的服务或后台操作失败时,通知仍走普通队列;独立运行或未注册的服务会保留队列投递。会话仍需加入房间才能收到通知。插件不会启动服务或扫描端口,移至后台的任务也不会被取消。消息每五秒轮询一次,并非即时推送。
|
|
57
59
|
|
|
60
|
+
### V2 常驻 watcher
|
|
61
|
+
|
|
62
|
+
运行 `opencode-chat-room watch start`,即可在关闭加载插件的项目后继续轮询 V2 消息。Watcher 使用当前用户已注册的 OpenCode 服务及已加入房间的所有者绑定,不会启动 OpenCode。中心模式下会继承执行该命令时的 `CHAT_ROOM_SERVER_URL` 和 `CHAT_ROOM_SERVER_TOKEN`。服务离线时,watcher 会继续运行并重试。`watch status` 检查经过认证的本机回环控制接口,`watch stop` 会优雅停止,`watch run` 则在前台运行。可手动启动,也可交由操作系统的进程管理器监督;包不会安装开机启动服务,也不会在消息收发时自动启动 watcher。私有控制状态和跨进程投递租约保存在用户的 XDG 状态目录中。若状态显示控制文件无法读取,请确认 watcher 已停止后,仅删除该用户的 `watch-*.json`;默认目录为 `~/.local/state/opencode/chat-room`。
|
|
63
|
+
|
|
58
64
|
## 中心模式(多主机)
|
|
59
65
|
|
|
60
66
|
多台机器时:跑一个中心服务器,所有客户端指向它。**每个客户端只需要这一个环境变量**。
|
|
@@ -63,17 +69,17 @@ V2 收到明确提及房间注册名称的消息(例如 `@alice`)时,会
|
|
|
63
69
|
|
|
64
70
|
```bash
|
|
65
71
|
# 查看 CLI 选项:
|
|
66
|
-
npx --yes --package=@alexsun-top/opencode-chat-room@0.2.
|
|
72
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.2.2 -- opencode-chat-room --help
|
|
67
73
|
|
|
68
74
|
# 启动本地中心服务器(三选一):
|
|
69
|
-
npx --yes --package=@alexsun-top/opencode-chat-room@0.2.
|
|
70
|
-
pnpx --package=@alexsun-top/opencode-chat-room@0.2.
|
|
71
|
-
bunx @alexsun-top/opencode-chat-room@0.2.
|
|
75
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.2.2 -- opencode-chat-room --host 0.0.0.0 --port 4399
|
|
76
|
+
pnpx --package=@alexsun-top/opencode-chat-room@0.2.2 opencode-chat-room --host 0.0.0.0 --port 4399
|
|
77
|
+
bunx @alexsun-top/opencode-chat-room@0.2.2 --host 0.0.0.0 --port 4399 --token secret
|
|
72
78
|
|
|
73
79
|
# 也可以使用环境变量;CLI 参数优先:
|
|
74
80
|
CHAT_ROOM_SERVER_HOST=127.0.0.1 CHAT_ROOM_SERVER_PORT=4399 \
|
|
75
81
|
CHAT_ROOM_SERVER_TOKEN=secret \
|
|
76
|
-
bunx @alexsun-top/opencode-chat-room@0.2.
|
|
82
|
+
bunx @alexsun-top/opencode-chat-room@0.2.2
|
|
77
83
|
|
|
78
84
|
# 本地 checkout:
|
|
79
85
|
bun install
|
|
@@ -101,7 +107,7 @@ export CHAT_ROOM_SERVER_TOKEN=secret # 仅当服务器设置了 token 时
|
|
|
101
107
|
| `HOST` | 服务器 | 主机名别名,仅在未设置 `CHAT_ROOM_SERVER_HOST` 时使用 | 未设置 |
|
|
102
108
|
| `CHAT_ROOM_SERVER_PORT` | 服务器 | 中心服务器监听端口;优先于 `PORT` | `4399` |
|
|
103
109
|
| `PORT` | 服务器 | 端口别名,仅在未设置 `CHAT_ROOM_SERVER_PORT` 时使用 | 未设置 |
|
|
104
|
-
| `CHAT_ROOM_STATE_DIR` | 单机模式 |
|
|
110
|
+
| `CHAT_ROOM_STATE_DIR` | 单机模式 | SQLite 数据库及迁移源 JSON 文件所在目录;必须位于本地文件系统 | `~/.config/opencode/chat-room/` |
|
|
105
111
|
| `OPENCODE_SERVER_PASSWORD` | 双端 | opencode 服务器密码;跨会话推送时用作 Basic 认证 | 无 |
|
|
106
112
|
| `CHAT_ROOM_WAKE_SERVE_URL` | 客户端 | 可选的 OpenCode serve 地址,用于兜底唤醒被提及的非活动会话 | 未设置 |
|
|
107
113
|
|
|
@@ -128,9 +134,8 @@ export CHAT_ROOM_SERVER_TOKEN=secret # 仅当服务器设置了 token 时
|
|
|
128
134
|
|
|
129
135
|
## 已知限制
|
|
130
136
|
|
|
131
|
-
-
|
|
132
|
-
- 共享目录的多主机单机模式依赖时间戳比较,各机器需 NTP 对时。中心模式不受影响(由服务器统一打时间戳)。
|
|
137
|
+
- 单机模式通过 SQLite WAL 和跨进程事务保存状态。数据库必须位于本地文件系统;多主机场景请使用中心模式,不要共享 WAL 数据库目录。
|
|
133
138
|
- 同一台机器的会话共享 `user@host` 身份;用不同的 `name` 加入以区分成员。
|
|
134
139
|
- 中心服务器不设 `CHAT_ROOM_SERVER_TOKEN` 时无认证——任何能访问端口的人都能读写房间。服务端另有输入限制:房间/成员名 ≤ 64 字符、消息文本 ≤ 2000 字符(超限返回 400)。
|
|
135
|
-
-
|
|
140
|
+
- SQLite 持续保留历史消息,不自动删除。500 条只是内存工作窗口,不是磁盘保留上限;未读消息和历史记录均分页读取。请定期备份数据库。
|
|
136
141
|
- `notify.log` 会持续增长,暂无轮转。
|
package/cli.ts
CHANGED
|
@@ -7,7 +7,10 @@ Options:
|
|
|
7
7
|
-v, --version Show the package version
|
|
8
8
|
-H, --host <host> Bind hostname
|
|
9
9
|
-p, --port <port> Bind port (1-65535)
|
|
10
|
-
-t, --token <token> Enable bearer token authentication
|
|
10
|
+
-t, --token <token> Enable bearer token authentication
|
|
11
|
+
|
|
12
|
+
Commands:
|
|
13
|
+
watch run|start|status|stop`;
|
|
11
14
|
|
|
12
15
|
type ValueOption = "host" | "port" | "token";
|
|
13
16
|
const values: Partial<Record<ValueOption, string>> = {};
|
|
@@ -34,6 +37,28 @@ function validatePort(value: string): void {
|
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
const args = process.argv.slice(2);
|
|
40
|
+
if (args[0] === "watch") {
|
|
41
|
+
const action = args[1];
|
|
42
|
+
if ((args.length === 2 && (action === "help" || action === "--help")) ||
|
|
43
|
+
(args.length === 3 && args[2] === "--help")) {
|
|
44
|
+
console.log("Usage: opencode-chat-room watch run|start|status|stop");
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}
|
|
47
|
+
if (args.length !== 2 || !["run", "start", "status", "stop"].includes(action ?? "")) {
|
|
48
|
+
fail("Expected watch run, start, status, or stop");
|
|
49
|
+
}
|
|
50
|
+
const watcher = await import("./src/watch");
|
|
51
|
+
try {
|
|
52
|
+
if (action === "run") await watcher.runWatcher();
|
|
53
|
+
else if (action === "start") console.log(await watcher.startWatcher());
|
|
54
|
+
else if (action === "status") console.log(await watcher.watchStatus());
|
|
55
|
+
else console.log(await watcher.stopWatcher());
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error(`watch: ${error instanceof Error ? error.message : "operation failed"}`);
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
}
|
|
60
|
+
process.exit(process.exitCode ?? 0);
|
|
61
|
+
}
|
|
37
62
|
for (let i = 0; i < args.length; i += 1) {
|
|
38
63
|
const arg = args[i]!;
|
|
39
64
|
if (arg === "-h" || arg === "--help") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexsun-top/opencode-chat-room",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A chat-room plugin and central server for OpenCode.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
"src",
|
|
26
26
|
"!src/**/*.test.ts",
|
|
27
27
|
"server/chat-server.ts",
|
|
28
|
+
"server/inbox.ts",
|
|
29
|
+
"server/history-route.ts",
|
|
30
|
+
"server/wake.ts",
|
|
28
31
|
"server/chat.html",
|
|
29
32
|
"CHANGELOG.md",
|
|
30
33
|
"README.md",
|