@reachdevel/opencode-git-commit 2.0.0 → 2.0.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/dist/index.js +13 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,6 +3,14 @@ import { promisify } from "node:util";
|
|
|
3
3
|
import { Plugin } from "@opencode/plugin";
|
|
4
4
|
const exec = promisify(execFile);
|
|
5
5
|
const SERVICE = "git-autocommit";
|
|
6
|
+
const TERMINAL = new Set([
|
|
7
|
+
"session.execution.succeeded",
|
|
8
|
+
"session.execution.failed",
|
|
9
|
+
"session.execution.interrupted",
|
|
10
|
+
]);
|
|
11
|
+
function isTerminal(event) {
|
|
12
|
+
return TERMINAL.has(event.type);
|
|
13
|
+
}
|
|
6
14
|
function log(level, message) {
|
|
7
15
|
const line = `[${SERVICE}] ${message}`;
|
|
8
16
|
if (level === "error")
|
|
@@ -80,11 +88,12 @@ const GitAutocommitPlugin = Plugin.define({
|
|
|
80
88
|
};
|
|
81
89
|
void (async () => {
|
|
82
90
|
for await (const event of ctx.event.subscribe({ signal: controller.signal })) {
|
|
83
|
-
|
|
91
|
+
// OpenCode v2 does not publish session.idle to plugins. The terminal
|
|
92
|
+
// execution events are what actually signal the session finished.
|
|
93
|
+
if (!isTerminal(event))
|
|
84
94
|
continue;
|
|
85
|
-
log("debug",
|
|
86
|
-
|
|
87
|
-
await run(directory, event.data.sessionID);
|
|
95
|
+
log("debug", `Session finished (${event.type})`);
|
|
96
|
+
await run(ctx.location.directory, event.data.sessionID);
|
|
88
97
|
}
|
|
89
98
|
})();
|
|
90
99
|
return () => controller.abort();
|
package/package.json
CHANGED