@ai-setting/roy-task-plugin 0.1.0 → 0.3.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Roy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # @ai-setting/roy-task-plugin
2
+
3
+ OpenCode plugin for **business-semantic task management**, plus the `roy-task`
4
+ CLI that bridges Feishu (Lark) messages to an OpenCode agent.
5
+
6
+ > **Requires only Node.js ≥ 20.** The `roy-task` CLI runs on plain node — no
7
+ > bun, no compilation, no build step. `npm i` and you are done.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @ai-setting/roy-task-plugin
13
+ ```
14
+
15
+ That gives you two things:
16
+
17
+ | Artifact | Entry | Runtime |
18
+ |---|---|---|
19
+ | OpenCode plugin | `dist/index.js` | loaded by opencode (bun) |
20
+ | `roy-task` CLI | `dist/cli.js` | **plain node ≥ 20** |
21
+
22
+ ## `roy-task` — Feishu ↔ agent bridge
23
+
24
+ ```bash
25
+ npx roy-task --help
26
+ npx roy-task version
27
+ npx roy-task status --profile default
28
+ npx roy-task serve --profile default
29
+ ```
30
+
31
+ | Command | What it does |
32
+ |---|---|
33
+ | `roy-task status` | Read-only pre-flight: is an event consumer already running for this app? is the opencode `roy` agent visible? |
34
+ | `roy-task serve` | Consume Feishu events and dispatch them to `opencode run --agent roy`, then reply. |
35
+ | `roy-task serve --dry-run` | Listen and log, but never spawn an agent and never reply. |
36
+ | `roy-task serve --once` | Handle exactly one event, then exit (testing / CI). |
37
+
38
+ ### ⚠️ One consumer per (app, EventKey)
39
+
40
+ `lark-cli` allows exactly **one** `event consume` per app+EventKey. A second one
41
+ does not error — it silently **splits** the event stream, so messages get
42
+ delivered to the wrong handler or dropped. That is why `--profile` is a
43
+ first-class flag: pick an app whose events nothing else is consuming.
44
+
45
+ `roy-task status` checks this for you before you start.
46
+
47
+ ### `--profile` matters for more than event routing
48
+
49
+ Feishu `openId` / `chatId` are **per-app isolated**. A reply sent through the
50
+ wrong app produces `99992361 open_id cross app`. Session ids are therefore
51
+ derived from `(profile, chatId)`, never from `chatId` alone.
52
+
53
+ ## Plugin usage
54
+
55
+ The plugin half is unchanged — see the repository README for hook behaviour,
56
+ persistence modes (local SQLite / remote HTTP) and the audit chain.
57
+
58
+ ## Notes on the build
59
+
60
+ - `dist/index.js` is **bundled** (`--packages=bundle`): opencode loads it with
61
+ no `node_modules` resolution needed.
62
+ - `dist/cli.js` is **external** (`--target=node --packages=external`, 35 KB):
63
+ it keeps `@ai-setting/roy-agent-core` as a real dependency so npm can dedupe
64
+ it, instead of vendoring ~1 MB of core into this package.
65
+ - `stdin` is forced to EOF (`stdio[0] = "ignore"`) for every child process.
66
+ `opencode run` calls `readStdin()`, which only resolves at EOF — on an
67
+ inherited socket it hangs for ~45 s. The long-lived `lark-cli event consume`
68
+ needs the opposite (stdin must stay open); it is spawned by roy-agent-core,
69
+ not by this CLI.
70
+
71
+ ## License
72
+
73
+ MIT