@scrylog/opencode-plugin 0.4.2 → 0.5.1
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.md +17 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +7 -5
- package/dist/shared.d.ts +2 -2
- package/dist/shared.js +5 -5
- package/package.json +39 -27
package/README.md
CHANGED
|
@@ -8,10 +8,11 @@ This is the recommended OpenCode integration when `scrylog` is running in `hooks
|
|
|
8
8
|
|
|
9
9
|
Use this plugin when:
|
|
10
10
|
|
|
11
|
-
- you
|
|
12
|
-
- you want `scrylog` to receive immediate session updates
|
|
13
|
-
- you want the best available correlation between OpenCode sessions and `tmux` panes
|
|
11
|
+
- you want `scrylog` to receive immediate, webhook-driven OpenCode session updates
|
|
14
12
|
- you want `hooks` mode, which is the recommended OpenCode mode in `scrylog`
|
|
13
|
+
- you run OpenCode inside `tmux` and want the best available pane correlation with `tmux` panes
|
|
14
|
+
|
|
15
|
+
The plugin forwards events regardless of your environment; `tmux` correlation is optional and only applies when OpenCode runs inside a `tmux` pane.
|
|
15
16
|
|
|
16
17
|
Do not use this plugin as your primary integration when:
|
|
17
18
|
|
|
@@ -137,8 +138,8 @@ That confirms local daemon reachability and current OpenCode mode.
|
|
|
137
138
|
|
|
138
139
|
The plugin uses one environment variable:
|
|
139
140
|
|
|
140
|
-
| Variable
|
|
141
|
-
|
|
|
141
|
+
| Variable | Default | Purpose |
|
|
142
|
+
| ------------- | -------------------------------------------- | ----------------------------------------- |
|
|
142
143
|
| `SCRYLOG_URL` | `http://127.0.0.1:7788/api/webhook/opencode` | Full webhook URL for the `scrylog` daemon |
|
|
143
144
|
|
|
144
145
|
### Example: custom daemon port
|
|
@@ -169,17 +170,17 @@ export SCRYLOG_URL=http://127.0.0.1:9000/api/webhook/opencode
|
|
|
169
170
|
|
|
170
171
|
The plugin forwards these OpenCode events:
|
|
171
172
|
|
|
172
|
-
| Event
|
|
173
|
-
|
|
|
174
|
-
| `session.created`
|
|
175
|
-
| `session.updated`
|
|
176
|
-
| `session.deleted`
|
|
177
|
-
| `session.status`
|
|
178
|
-
| `session.idle`
|
|
179
|
-
| `session.error`
|
|
180
|
-
| `permission.updated` | Permission prompt state updated
|
|
181
|
-
| `permission.asked`
|
|
182
|
-
| `permission.replied` | Permission prompt answered
|
|
173
|
+
| Event | Meaning |
|
|
174
|
+
| -------------------- | ------------------------------------------------- |
|
|
175
|
+
| `session.created` | New session created |
|
|
176
|
+
| `session.updated` | Session metadata changed |
|
|
177
|
+
| `session.deleted` | Session deleted |
|
|
178
|
+
| `session.status` | State changed, such as `busy`, `idle`, or `retry` |
|
|
179
|
+
| `session.idle` | Explicit idle signal |
|
|
180
|
+
| `session.error` | Session error |
|
|
181
|
+
| `permission.updated` | Permission prompt state updated |
|
|
182
|
+
| `permission.asked` | Permission prompt shown |
|
|
183
|
+
| `permission.replied` | Permission prompt answered |
|
|
183
184
|
|
|
184
185
|
## Request Format
|
|
185
186
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as server } from
|
|
1
|
+
export { default as server } from './server';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as server } from
|
|
1
|
+
export { default as server } from './server';
|
package/dist/server.d.ts
CHANGED
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getTmuxPane, getWebhookUrl, post, setTmuxSessionOption } from
|
|
1
|
+
import { getTmuxPane, getWebhookUrl, post, setTmuxSessionOption, } from './shared';
|
|
2
2
|
export const ScrylogServerPlugin = async (input) => {
|
|
3
|
-
const { client, directory
|
|
3
|
+
const { $, client, directory } = input;
|
|
4
4
|
const webhookUrl = getWebhookUrl();
|
|
5
5
|
if (getTmuxPane()) {
|
|
6
6
|
client.session
|
|
@@ -8,6 +8,7 @@ export const ScrylogServerPlugin = async (input) => {
|
|
|
8
8
|
.then(({ data }) => {
|
|
9
9
|
if (!data?.length)
|
|
10
10
|
return;
|
|
11
|
+
// eslint-disable-next-line prefer-destructuring
|
|
11
12
|
const latest = [...data]
|
|
12
13
|
.filter((s) => !s.parentID)
|
|
13
14
|
.sort((a, b) => (b.time.updated ?? 0) - (a.time.updated ?? 0))[0];
|
|
@@ -19,14 +20,15 @@ export const ScrylogServerPlugin = async (input) => {
|
|
|
19
20
|
return {
|
|
20
21
|
event: async ({ event }) => {
|
|
21
22
|
post(webhookUrl, {
|
|
22
|
-
event: event.type,
|
|
23
23
|
directory,
|
|
24
|
+
event: event.type,
|
|
24
25
|
...event.properties,
|
|
25
26
|
});
|
|
26
|
-
if (event.type ===
|
|
27
|
+
if (event.type === 'session.created' ||
|
|
28
|
+
event.type === 'session.updated') {
|
|
27
29
|
const sessionID = event.properties.info?.id;
|
|
28
30
|
const parentID = event.properties.info?.parentID;
|
|
29
|
-
if (typeof sessionID ===
|
|
31
|
+
if (typeof sessionID === 'string' && !parentID)
|
|
30
32
|
setTmuxSessionOption(sessionID, $);
|
|
31
33
|
}
|
|
32
34
|
},
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { PluginInput } from
|
|
1
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
2
2
|
export declare const DEFAULT_WEBHOOK_URL = "http://127.0.0.1:7788/api/webhook/opencode";
|
|
3
3
|
export declare function getWebhookUrl(): string;
|
|
4
4
|
export declare function post(webhookUrl: string, body: Record<string, unknown>): void;
|
|
5
5
|
export declare function getTmuxPane(): string | undefined;
|
|
6
|
-
export declare function setTmuxSessionOption(sessionID: string, $?: PluginInput[
|
|
6
|
+
export declare function setTmuxSessionOption(sessionID: string, $?: PluginInput['$']): void;
|
package/dist/shared.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export const DEFAULT_WEBHOOK_URL =
|
|
1
|
+
export const DEFAULT_WEBHOOK_URL = 'http://127.0.0.1:7788/api/webhook/opencode';
|
|
2
2
|
export function getWebhookUrl() {
|
|
3
|
-
return process.env[
|
|
3
|
+
return process.env['SCRYLOG_URL'] ?? DEFAULT_WEBHOOK_URL;
|
|
4
4
|
}
|
|
5
5
|
export function post(webhookUrl, body) {
|
|
6
6
|
fetch(webhookUrl, {
|
|
7
|
-
method: "POST",
|
|
8
|
-
headers: { "Content-Type": "application/json" },
|
|
9
7
|
body: JSON.stringify(body),
|
|
8
|
+
headers: { 'Content-Type': 'application/json' },
|
|
9
|
+
method: 'POST',
|
|
10
10
|
}).catch(() => {
|
|
11
11
|
// Ignore all errors — daemon may not be running
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
export function getTmuxPane() {
|
|
15
|
-
const pane = process.env[
|
|
15
|
+
const pane = process.env['TMUX_PANE'];
|
|
16
16
|
if (!pane)
|
|
17
17
|
return undefined;
|
|
18
18
|
if (!/^%\d+$/.test(pane))
|
package/package.json
CHANGED
|
@@ -1,53 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrylog/opencode-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "OpenCode plugin that pushes session events to scrylog daemon",
|
|
5
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"hooks",
|
|
7
|
+
"opencode",
|
|
8
|
+
"plugin",
|
|
9
|
+
"scrylog",
|
|
10
|
+
"webhook"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/scrylog/scrylog/tree/main/packages/opencode-plugin#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/scrylog/scrylog/issues"
|
|
15
|
+
},
|
|
6
16
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
"main": "./dist/index.js",
|
|
9
|
-
"module": "./dist/index.js",
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
17
|
+
"author": "Joel D. Martinez",
|
|
11
18
|
"repository": {
|
|
12
19
|
"type": "git",
|
|
13
20
|
"url": "git+https://github.com/scrylog/scrylog.git",
|
|
14
21
|
"directory": "packages/opencode-plugin"
|
|
15
22
|
},
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"module": "./dist/index.js",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
20
32
|
"exports": {
|
|
21
33
|
".": {
|
|
22
34
|
"import": "./dist/index.js",
|
|
23
35
|
"types": "./dist/index.d.ts"
|
|
24
36
|
}
|
|
25
37
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"LICENSE"
|
|
30
|
-
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
31
41
|
"scripts": {
|
|
32
42
|
"build": "tsc",
|
|
33
43
|
"check-types": "tsc --noEmit",
|
|
34
44
|
"clean": "rm -rf .turbo && rm -rf dist",
|
|
35
45
|
"clean:node-modules": "rm -rf node_modules",
|
|
36
46
|
"dev": "tsc --watch",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
47
|
+
"lint": "concurrently --kill-others-on-fail \"bun lint:fmt\" \"bun lint:oxc\" \"bun lint:eslint\" \"bun lint:tsc\"",
|
|
48
|
+
"lint:eslint": "eslint ./src --max-warnings 0",
|
|
49
|
+
"lint:eslint:fix": "bun lint:eslint -- --fix",
|
|
50
|
+
"lint:fmt": "bun --bun oxfmt --check",
|
|
51
|
+
"lint:fmt:fix": "bun --bun oxfmt",
|
|
52
|
+
"lint:oxc": "oxlint --tsconfig ./tsconfig.json --deny-warnings",
|
|
53
|
+
"lint:oxc:fix": "bun lint:oxc -- --fix --fix-suggestions",
|
|
54
|
+
"lint:oxc:type-aware": "bun lint:oxc -- --type-aware",
|
|
55
|
+
"lint:oxc:type-check": "bun lint:oxc:type-aware -- --type-check",
|
|
56
|
+
"lint:tsc": "bun tsc --noEmit",
|
|
57
|
+
"lint:tsc:go": "bun tsgo --project ./tsconfig.base.json --noEmit",
|
|
58
|
+
"pack:dry-run": "bash ../../scripts/npm-pack.sh \"$PWD\" \"\" --dry-run",
|
|
59
|
+
"prepack": "npm run build"
|
|
49
60
|
},
|
|
50
61
|
"devDependencies": {
|
|
62
|
+
"@mainqueueio/eslint-config": "0.2.1-next.14",
|
|
51
63
|
"@opencode-ai/plugin": "1.4.0",
|
|
52
64
|
"@opencode-ai/sdk": "1.4.10",
|
|
53
65
|
"@types/node": "^24.3.0",
|