opencode-immune 1.0.29 → 1.0.31

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 +23 -28
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -615,10 +615,12 @@ async function fetchLatestHarnessRelease(repo, token) {
615
615
  const tagName = data.tag_name;
616
616
  if (!tagName)
617
617
  return null;
618
- // Find the harness.tar.gz asset
619
- const asset = data.assets?.find((a) => a.name === "harness.tar.gz");
618
+ // Find the correct harness asset based on OS
619
+ const isWindows = process.platform === "win32";
620
+ const assetName = isWindows ? "harness-windows.tar.gz" : "harness.tar.gz";
621
+ const asset = data.assets?.find((a) => a.name === assetName);
620
622
  if (!asset) {
621
- console.warn(`[opencode-immune] Harness sync: release ${tagName} has no harness.tar.gz asset`);
623
+ console.warn(`[opencode-immune] Harness sync: release ${tagName} has no ${assetName} asset`);
622
624
  return null;
623
625
  }
624
626
  return {
@@ -684,17 +686,22 @@ function extractTarGz(archivePath, destDir) {
684
686
  /**
685
687
  * Recursively copy all files from src to dest, creating directories as needed.
686
688
  * Overwrites existing files.
689
+ * skipRootFiles: file names to skip ONLY when dest === rootDest (top-level copy target).
687
690
  */
688
- async function copyDirRecursive(src, dest, skipFiles) {
691
+ async function copyDirRecursive(src, dest, skipRootFiles, rootDest) {
692
+ const effectiveRoot = rootDest ?? dest;
689
693
  const entries = await (0, promises_1.readdir)(src, { withFileTypes: true });
690
694
  await (0, promises_1.mkdir)(dest, { recursive: true });
691
695
  for (const entry of entries) {
692
- if (skipFiles?.has(entry.name))
696
+ // Skip files only at the root destination level
697
+ if (skipRootFiles && dest === effectiveRoot && entry.name === ".gitignore") {
698
+ console.log(`[opencode-immune] Harness sync: skipping root .gitignore`);
693
699
  continue;
700
+ }
694
701
  const srcPath = (0, path_1.join)(src, entry.name);
695
702
  const destPath = (0, path_1.join)(dest, entry.name);
696
703
  if (entry.isDirectory()) {
697
- await copyDirRecursive(srcPath, destPath);
704
+ await copyDirRecursive(srcPath, destPath, skipRootFiles, effectiveRoot);
698
705
  }
699
706
  else {
700
707
  await (0, promises_1.mkdir)((0, path_1.dirname)(destPath), { recursive: true });
@@ -1306,27 +1313,15 @@ async function loadCommitPrompt() {
1306
1313
  }
1307
1314
  }
1308
1315
  /**
1309
- * Execute a commit by sending the /commit prompt to a new session.
1316
+ * Execute a commit by sending the /commit prompt to the current session.
1310
1317
  * The agent will analyze the diff and create a proper commit message.
1311
1318
  * Returns true if the prompt was sent successfully.
1312
1319
  */
1313
- async function runSmartCommit(state) {
1320
+ async function runSmartCommit(state, sessionID) {
1314
1321
  try {
1315
1322
  const commitPrompt = await loadCommitPrompt();
1316
- // Create a dedicated session for the commit
1317
- const createResult = await state.input.client.session.create({
1318
- body: {
1319
- title: "Auto-commit (ultrawork cycle)",
1320
- },
1321
- });
1322
- const sessionData = createResult?.data;
1323
- const commitSessionID = sessionData?.id;
1324
- if (!commitSessionID) {
1325
- console.error("[opencode-immune] Smart commit: failed to create session.");
1326
- return false;
1327
- }
1328
- console.log(`[opencode-immune] Smart commit: session created ${commitSessionID}, sending commit prompt...`);
1329
- // Send commit prompt and wait for completion (sync prompt, not async)
1323
+ console.log(`[opencode-immune] Smart commit: sending commit prompt to session ${sessionID}...`);
1324
+ // Send commit prompt to the SAME session (ultrawork already finished, session is free)
1330
1325
  await state.input.client.session.prompt({
1331
1326
  body: {
1332
1327
  parts: [
@@ -1336,7 +1331,7 @@ async function runSmartCommit(state) {
1336
1331
  },
1337
1332
  ],
1338
1333
  },
1339
- path: { id: commitSessionID },
1334
+ path: { id: sessionID },
1340
1335
  });
1341
1336
  console.log("[opencode-immune] Smart commit: completed.");
1342
1337
  return true;
@@ -1403,11 +1398,11 @@ function createTextCompleteHandler(state) {
1403
1398
  }
1404
1399
  // ── PRE_COMMIT only (without CYCLE_COMPLETE in same part): run commit ──
1405
1400
  if (text.includes(PRE_COMMIT_MARKER) && !text.includes(CYCLE_COMPLETE_MARKER)) {
1406
- if (!state.commitPending) {
1401
+ if (!state.commitPending && sessionID) {
1407
1402
  state.commitPending = true;
1408
1403
  console.log("[opencode-immune] Multi-Cycle: PRE_COMMIT detected (standalone), running smart commit...");
1409
1404
  try {
1410
- const ok = await runSmartCommit(state);
1405
+ const ok = await runSmartCommit(state, sessionID);
1411
1406
  if (!ok) {
1412
1407
  console.log("[opencode-immune] Multi-Cycle: smart commit failed, falling back to git commit...");
1413
1408
  await runGitCommit(state.input.directory, "chore: ultrawork cycle auto-commit");
@@ -1424,12 +1419,12 @@ function createTextCompleteHandler(state) {
1424
1419
  }
1425
1420
  // ── CYCLE_COMPLETE: self-contained sequence: commit → new session ──
1426
1421
  if (text.includes(CYCLE_COMPLETE_MARKER)) {
1427
- // Step 1: Always commit first (CYCLE_COMPLETE implies end of cycle)
1428
- if (!state.commitPending) {
1422
+ // Step 1: Always commit first in the current session
1423
+ if (!state.commitPending && sessionID) {
1429
1424
  state.commitPending = true;
1430
1425
  console.log("[opencode-immune] Multi-Cycle: CYCLE_COMPLETE detected, running smart commit first...");
1431
1426
  try {
1432
- const ok = await runSmartCommit(state);
1427
+ const ok = await runSmartCommit(state, sessionID);
1433
1428
  if (!ok) {
1434
1429
  console.log("[opencode-immune] Multi-Cycle: smart commit failed, falling back to git commit...");
1435
1430
  await runGitCommit(state.input.directory, "chore: ultrawork cycle auto-commit");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-immune",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
5
5
  "exports": {
6
6
  "./server": "./dist/plugin.js"