omo-plannotator-bridge 0.1.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.
Files changed (3) hide show
  1. package/README.md +15 -0
  2. package/index.ts +76 -0
  3. package/package.json +21 -0
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # omo-plannotator-bridge
2
+
3
+ To install dependencies:
4
+
5
+ ```bash
6
+ bun install
7
+ ```
8
+
9
+ To run:
10
+
11
+ ```bash
12
+ bun run index.ts
13
+ ```
14
+
15
+ This project was created using `bun init` in bun v1.3.5. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
package/index.ts ADDED
@@ -0,0 +1,76 @@
1
+ import type { Hooks, Plugin, PluginInput } from "@opencode-ai/plugin";
2
+ import type { Part, UserMessage } from "@opencode-ai/sdk";
3
+
4
+ const BRIDGE_HEADER = "<!-- omo-plannotator-bridge -->";
5
+
6
+ const getUserAgent = async (
7
+ pluginInput: PluginInput,
8
+ sessionId: string | undefined,
9
+ ) => {
10
+ if (!sessionId) return;
11
+
12
+ const messagesResponse = await pluginInput.client.session.messages({
13
+ path: { id: sessionId },
14
+ });
15
+ return messagesResponse.data
16
+ ?.find(
17
+ (message): message is { info: UserMessage; parts: Part[] } =>
18
+ message.info.role === "user",
19
+ )
20
+ ?.info.agent.toLowerCase();
21
+ };
22
+
23
+ const interceptPlannotatorApprove = (parts: Part[]): Part[] =>
24
+ parts.map((part) => {
25
+ if (part.type === "text" && part.text === "Proceed with implementation") {
26
+ return { ...part, text: "" };
27
+ }
28
+ return part;
29
+ });
30
+
31
+ const plugin: Plugin = async (pluginInput) => {
32
+ const hooks: Hooks = {
33
+ "chat.message": async (_, output) => {
34
+ output.parts = interceptPlannotatorApprove(output.parts);
35
+ },
36
+
37
+ "experimental.chat.messages.transform": async (_, output) => {
38
+ output.messages.forEach((message) => {
39
+ message.parts = interceptPlannotatorApprove(message.parts);
40
+ });
41
+ },
42
+
43
+ "experimental.chat.system.transform": async (input, output) => {
44
+ const systemPrompt = output.system.join("\n").toLowerCase();
45
+ const alreadyInjected = systemPrompt.includes(BRIDGE_HEADER);
46
+ if (alreadyInjected) return;
47
+
48
+ const userAgent = await getUserAgent(pluginInput, input.sessionID);
49
+ const isPrometheus =
50
+ userAgent === "prometheus" || systemPrompt.includes("prometheus");
51
+ const isSisyphus =
52
+ userAgent === "sisyphus" ||
53
+ (systemPrompt.includes("sisyphus") &&
54
+ !systemPrompt.includes("sisyphus-junior"));
55
+
56
+ if (isPrometheus) {
57
+ output.system.push(`${BRIDGE_HEADER}
58
+ ## Plan Submission
59
+
60
+ Once the plan is complete, you must call the submit_plan tool to get user review.
61
+ You must call submit_plan before asking about Start Work / High Accuracy.
62
+ Once the user approves, ask about Start Work / High Accuracy.`);
63
+ } else if (isSisyphus) {
64
+ output.system.push(`${BRIDGE_HEADER}
65
+ ## Plan Submission
66
+
67
+ Before proceeding with important work steps, call the submit_plan tool to get user confirmation.
68
+ Use this when confirmation is needed, such as "Should I proceed this way?" or "Is it okay to go in this direction?"`);
69
+ }
70
+ },
71
+ };
72
+
73
+ return hooks;
74
+ };
75
+
76
+ export default plugin;
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "omo-plannotator-bridge",
3
+ "version": "0.1.0",
4
+ "main": "index.ts",
5
+ "files": ["index.ts"],
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "scripts": {
10
+ "format:fix": "prettier --write *.ts"
11
+ },
12
+ "devDependencies": {
13
+ "@opencode-ai/plugin": "^1.2.10",
14
+ "@opencode-ai/sdk": "^1.2.10",
15
+ "@types/bun": "latest",
16
+ "prettier": "^3.8.1"
17
+ },
18
+ "peerDependencies": {
19
+ "typescript": "^5"
20
+ }
21
+ }