opencode-immune 1.0.78 → 1.0.79

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.
@@ -3777,7 +3777,7 @@ import { fileURLToPath } from "url";
3777
3777
  import { createHash } from "crypto";
3778
3778
  import { tmpdir } from "os";
3779
3779
  import { execFile } from "child_process";
3780
- var PLUGIN_VERSION = "1.0.78";
3780
+ var PLUGIN_VERSION = "1.0.79";
3781
3781
  var PLUGIN_PACKAGE_NAME = "opencode-immune";
3782
3782
  var PLUGIN_DIRNAME = dirname(fileURLToPath(import.meta.url));
3783
3783
  function getServerAuthHeaders() {
@@ -5913,37 +5913,51 @@ function createTextCompleteHandler(state) {
5913
5913
  return;
5914
5914
  }
5915
5915
  if (text.includes(CYCLE_COMPLETE_MARKER)) {
5916
+ if (state.autoCycleInFlight || state.autoCycleSourceSessions.has(sessionID)) return;
5917
+ const lockAcquired2 = await acquireAutoCycleLock(
5918
+ state,
5919
+ "cycle-complete",
5920
+ sessionID
5921
+ );
5922
+ if (!lockAcquired2) return;
5923
+ state.autoCycleSourceSessions.add(sessionID);
5924
+ state.autoCycleInFlight = true;
5916
5925
  try {
5917
- await archiveProgress(state.input.directory);
5918
- } catch (err) {
5919
- pluginLog.warn("[opencode-immune] Multi-Cycle: archive progress failed:", err);
5920
- }
5921
- await commitCycleChanges(state, "CYCLE_COMPLETE detected");
5922
- state.cycleCount++;
5923
- if (state.cycleCount >= MAX_CYCLES) {
5926
+ try {
5927
+ await archiveProgress(state.input.directory);
5928
+ } catch (err) {
5929
+ pluginLog.warn("[opencode-immune] Multi-Cycle: archive progress failed:", err);
5930
+ }
5931
+ await commitCycleChanges(state, "CYCLE_COMPLETE detected");
5932
+ state.cycleCount++;
5933
+ if (state.cycleCount >= MAX_CYCLES) {
5934
+ pluginLog.info(
5935
+ `[opencode-immune] Multi-Cycle: MAX_CYCLES (${MAX_CYCLES}) reached. Not creating new session.`
5936
+ );
5937
+ await clearUltraworkMarker(state);
5938
+ await clearAutoCycleLock(state, "max cycles reached");
5939
+ return;
5940
+ }
5941
+ const taskMatch = text.match(NEXT_TASK_PATTERN);
5942
+ const nextTask = taskMatch?.[1]?.trim() ?? "Continue processing task backlog";
5924
5943
  pluginLog.info(
5925
- `[opencode-immune] Multi-Cycle: MAX_CYCLES (${MAX_CYCLES}) reached. Not creating new session.`
5944
+ `[opencode-immune] Multi-Cycle: Starting next cycle in a new session (cycle ${state.cycleCount}/${MAX_CYCLES}) for: "${nextTask}"`
5926
5945
  );
5927
- await clearUltraworkMarker(state);
5928
- return;
5929
- }
5930
- const taskMatch = text.match(NEXT_TASK_PATTERN);
5931
- const nextTask = taskMatch?.[1]?.trim() ?? "Continue processing task backlog";
5932
- pluginLog.info(
5933
- `[opencode-immune] Multi-Cycle: Starting next cycle in a new session (cycle ${state.cycleCount}/${MAX_CYCLES}) for: "${nextTask}"`
5934
- );
5935
- try {
5936
5946
  await startAutoCycleInNewSession(
5937
5947
  state,
5938
5948
  {
5939
5949
  sourceSessionID: sessionID,
5940
5950
  nextTask,
5941
5951
  logContext: "Multi-Cycle",
5952
+ clearLockOnFailureReason: "cycle complete bootstrap failed",
5942
5953
  retireSourceSession: true
5943
5954
  }
5944
5955
  );
5945
5956
  } catch (err) {
5957
+ state.autoCycleSourceSessions.delete(sessionID);
5946
5958
  pluginLog.error("[opencode-immune] Multi-Cycle: Failed to send prompt:", err);
5959
+ } finally {
5960
+ state.autoCycleInFlight = false;
5947
5961
  }
5948
5962
  return;
5949
5963
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-immune",
3
- "version": "1.0.78",
3
+ "version": "1.0.79",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
6
6
  "exports": {