@reachdevel/opencode-git-commit 2.0.2 → 2.0.3
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 +17 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -177,6 +177,18 @@ const GitAutocommitPlugin = Plugin.define({
|
|
|
177
177
|
pending.set(directory, settled);
|
|
178
178
|
return settled;
|
|
179
179
|
};
|
|
180
|
+
// Only commit on root session endings - skip subagent sessions so their
|
|
181
|
+
// work isn't committed while the parent task is still in flight.
|
|
182
|
+
async function isRootSession(sessionID) {
|
|
183
|
+
try {
|
|
184
|
+
const info = await ctx.session.get({ sessionID });
|
|
185
|
+
return !info?.parentID;
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
// If we can't determine parentage, run to avoid losing commits
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
180
192
|
void (async () => {
|
|
181
193
|
for await (const event of ctx.event.subscribe({ signal: controller.signal })) {
|
|
182
194
|
// OpenCode v2 does not publish session.idle to plugins. The terminal
|
|
@@ -184,6 +196,11 @@ const GitAutocommitPlugin = Plugin.define({
|
|
|
184
196
|
if (!isTerminal(event))
|
|
185
197
|
continue;
|
|
186
198
|
log("debug", `Session finished (${event.type})`);
|
|
199
|
+
// Skip subagent sessions: only root session endings trigger commits
|
|
200
|
+
if (!(await isRootSession(event.data.sessionID))) {
|
|
201
|
+
log("debug", `Skipping subagent session ${event.data.sessionID}`);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
187
204
|
await run(ctx.location.directory);
|
|
188
205
|
}
|
|
189
206
|
})();
|
package/package.json
CHANGED