opencode-immune 1.0.32 → 1.0.34

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 (2) hide show
  1. package/dist/plugin.js +48 -2
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -278,7 +278,14 @@ function isRetryableApiError(error) {
278
278
  message.includes("econnrefused") ||
279
279
  message.includes("econnreset") ||
280
280
  message.includes("etimedout") ||
281
- message.includes("fetch failed")) {
281
+ message.includes("fetch failed") ||
282
+ message.includes("timed out") ||
283
+ message.includes("timeout") ||
284
+ message.includes("sse read") ||
285
+ message.includes("stream error") ||
286
+ message.includes("connection reset") ||
287
+ message.includes("socket hang up") ||
288
+ message.includes("aborted")) {
282
289
  return true;
283
290
  }
284
291
  return false;
@@ -1284,6 +1291,38 @@ const PRE_COMMIT_MARKER = "0-ULTRAWORK: PRE_COMMIT";
1284
1291
  const CYCLE_COMPLETE_MARKER = "0-ULTRAWORK: CYCLE_COMPLETE";
1285
1292
  const NEXT_TASK_PATTERN = /Next task:\s*(.+)/;
1286
1293
  const ALL_CYCLES_COMPLETE_MARKER = "0-ULTRAWORK: ALL_CYCLES_COMPLETE";
1294
+ /**
1295
+ * Archive memory-bank/progress.md before a new cycle starts.
1296
+ * Moves to memory-bank/archive/progress-YYYY-MM-DD-{timestamp}.md.
1297
+ * Skips silently if progress.md doesn't exist or is trivially empty.
1298
+ */
1299
+ async function archiveProgress(directory) {
1300
+ const progressPath = (0, path_1.join)(directory, "memory-bank", "progress.md");
1301
+ try {
1302
+ const content = await (0, promises_1.readFile)(progressPath, "utf-8");
1303
+ // Skip if empty or trivially empty
1304
+ if (!content.trim() || content.trim() === "# Progress") {
1305
+ console.log("[opencode-immune] Archive progress: nothing to archive (empty).");
1306
+ return;
1307
+ }
1308
+ const archiveDir = (0, path_1.join)(directory, "memory-bank", "archive");
1309
+ await (0, promises_1.mkdir)(archiveDir, { recursive: true });
1310
+ const now = new Date();
1311
+ const dateStr = now.toISOString().slice(0, 10); // YYYY-MM-DD
1312
+ const ts = Math.floor(now.getTime() / 1000);
1313
+ const archiveName = `progress-${dateStr}-${ts}.md`;
1314
+ const archivePath = (0, path_1.join)(archiveDir, archiveName);
1315
+ await (0, promises_1.rename)(progressPath, archivePath);
1316
+ console.log(`[opencode-immune] Archive progress: moved to ${archiveName}`);
1317
+ }
1318
+ catch (err) {
1319
+ // File doesn't exist or move failed — not critical
1320
+ const msg = err instanceof Error ? err.message : String(err);
1321
+ if (!msg.includes("ENOENT")) {
1322
+ console.warn("[opencode-immune] Archive progress failed:", msg);
1323
+ }
1324
+ }
1325
+ }
1287
1326
  /**
1288
1327
  * Helper: run git add + diff-stat + commit with descriptive message.
1289
1328
  * Builds commit body from `git diff --cached --stat` so the commit
@@ -1361,8 +1400,15 @@ function createTextCompleteHandler(state) {
1361
1400
  }
1362
1401
  return;
1363
1402
  }
1364
- // ── CYCLE_COMPLETE: self-contained sequence: commit → new session ──
1403
+ // ── CYCLE_COMPLETE: self-contained sequence: archive progress → commit → new session ──
1365
1404
  if (text.includes(CYCLE_COMPLETE_MARKER)) {
1405
+ // Step 0: Archive progress.md before new cycle
1406
+ try {
1407
+ await archiveProgress(state.input.directory);
1408
+ }
1409
+ catch (err) {
1410
+ console.warn("[opencode-immune] Multi-Cycle: archive progress failed:", err);
1411
+ }
1366
1412
  // Step 1: Always commit first
1367
1413
  if (!state.commitPending) {
1368
1414
  state.commitPending = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-immune",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
5
5
  "exports": {
6
6
  "./server": "./dist/plugin.js"