opencode-immune 1.0.32 → 1.0.33
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/plugin.js +40 -1
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -1284,6 +1284,38 @@ const PRE_COMMIT_MARKER = "0-ULTRAWORK: PRE_COMMIT";
|
|
|
1284
1284
|
const CYCLE_COMPLETE_MARKER = "0-ULTRAWORK: CYCLE_COMPLETE";
|
|
1285
1285
|
const NEXT_TASK_PATTERN = /Next task:\s*(.+)/;
|
|
1286
1286
|
const ALL_CYCLES_COMPLETE_MARKER = "0-ULTRAWORK: ALL_CYCLES_COMPLETE";
|
|
1287
|
+
/**
|
|
1288
|
+
* Archive memory-bank/progress.md before a new cycle starts.
|
|
1289
|
+
* Moves to memory-bank/archive/progress-YYYY-MM-DD-{timestamp}.md.
|
|
1290
|
+
* Skips silently if progress.md doesn't exist or is trivially empty.
|
|
1291
|
+
*/
|
|
1292
|
+
async function archiveProgress(directory) {
|
|
1293
|
+
const progressPath = (0, path_1.join)(directory, "memory-bank", "progress.md");
|
|
1294
|
+
try {
|
|
1295
|
+
const content = await (0, promises_1.readFile)(progressPath, "utf-8");
|
|
1296
|
+
// Skip if empty or trivially empty
|
|
1297
|
+
if (!content.trim() || content.trim() === "# Progress") {
|
|
1298
|
+
console.log("[opencode-immune] Archive progress: nothing to archive (empty).");
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
const archiveDir = (0, path_1.join)(directory, "memory-bank", "archive");
|
|
1302
|
+
await (0, promises_1.mkdir)(archiveDir, { recursive: true });
|
|
1303
|
+
const now = new Date();
|
|
1304
|
+
const dateStr = now.toISOString().slice(0, 10); // YYYY-MM-DD
|
|
1305
|
+
const ts = Math.floor(now.getTime() / 1000);
|
|
1306
|
+
const archiveName = `progress-${dateStr}-${ts}.md`;
|
|
1307
|
+
const archivePath = (0, path_1.join)(archiveDir, archiveName);
|
|
1308
|
+
await (0, promises_1.rename)(progressPath, archivePath);
|
|
1309
|
+
console.log(`[opencode-immune] Archive progress: moved to ${archiveName}`);
|
|
1310
|
+
}
|
|
1311
|
+
catch (err) {
|
|
1312
|
+
// File doesn't exist or move failed — not critical
|
|
1313
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1314
|
+
if (!msg.includes("ENOENT")) {
|
|
1315
|
+
console.warn("[opencode-immune] Archive progress failed:", msg);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1287
1319
|
/**
|
|
1288
1320
|
* Helper: run git add + diff-stat + commit with descriptive message.
|
|
1289
1321
|
* Builds commit body from `git diff --cached --stat` so the commit
|
|
@@ -1361,8 +1393,15 @@ function createTextCompleteHandler(state) {
|
|
|
1361
1393
|
}
|
|
1362
1394
|
return;
|
|
1363
1395
|
}
|
|
1364
|
-
// ── CYCLE_COMPLETE: self-contained sequence: commit → new session ──
|
|
1396
|
+
// ── CYCLE_COMPLETE: self-contained sequence: archive progress → commit → new session ──
|
|
1365
1397
|
if (text.includes(CYCLE_COMPLETE_MARKER)) {
|
|
1398
|
+
// Step 0: Archive progress.md before new cycle
|
|
1399
|
+
try {
|
|
1400
|
+
await archiveProgress(state.input.directory);
|
|
1401
|
+
}
|
|
1402
|
+
catch (err) {
|
|
1403
|
+
console.warn("[opencode-immune] Multi-Cycle: archive progress failed:", err);
|
|
1404
|
+
}
|
|
1366
1405
|
// Step 1: Always commit first
|
|
1367
1406
|
if (!state.commitPending) {
|
|
1368
1407
|
state.commitPending = true;
|