opencode-immune 1.0.29 → 1.0.30

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 +10 -22
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -1306,27 +1306,15 @@ async function loadCommitPrompt() {
1306
1306
  }
1307
1307
  }
1308
1308
  /**
1309
- * Execute a commit by sending the /commit prompt to a new session.
1309
+ * Execute a commit by sending the /commit prompt to the current session.
1310
1310
  * The agent will analyze the diff and create a proper commit message.
1311
1311
  * Returns true if the prompt was sent successfully.
1312
1312
  */
1313
- async function runSmartCommit(state) {
1313
+ async function runSmartCommit(state, sessionID) {
1314
1314
  try {
1315
1315
  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)
1316
+ console.log(`[opencode-immune] Smart commit: sending commit prompt to session ${sessionID}...`);
1317
+ // Send commit prompt to the SAME session (ultrawork already finished, session is free)
1330
1318
  await state.input.client.session.prompt({
1331
1319
  body: {
1332
1320
  parts: [
@@ -1336,7 +1324,7 @@ async function runSmartCommit(state) {
1336
1324
  },
1337
1325
  ],
1338
1326
  },
1339
- path: { id: commitSessionID },
1327
+ path: { id: sessionID },
1340
1328
  });
1341
1329
  console.log("[opencode-immune] Smart commit: completed.");
1342
1330
  return true;
@@ -1403,11 +1391,11 @@ function createTextCompleteHandler(state) {
1403
1391
  }
1404
1392
  // ── PRE_COMMIT only (without CYCLE_COMPLETE in same part): run commit ──
1405
1393
  if (text.includes(PRE_COMMIT_MARKER) && !text.includes(CYCLE_COMPLETE_MARKER)) {
1406
- if (!state.commitPending) {
1394
+ if (!state.commitPending && sessionID) {
1407
1395
  state.commitPending = true;
1408
1396
  console.log("[opencode-immune] Multi-Cycle: PRE_COMMIT detected (standalone), running smart commit...");
1409
1397
  try {
1410
- const ok = await runSmartCommit(state);
1398
+ const ok = await runSmartCommit(state, sessionID);
1411
1399
  if (!ok) {
1412
1400
  console.log("[opencode-immune] Multi-Cycle: smart commit failed, falling back to git commit...");
1413
1401
  await runGitCommit(state.input.directory, "chore: ultrawork cycle auto-commit");
@@ -1424,12 +1412,12 @@ function createTextCompleteHandler(state) {
1424
1412
  }
1425
1413
  // ── CYCLE_COMPLETE: self-contained sequence: commit → new session ──
1426
1414
  if (text.includes(CYCLE_COMPLETE_MARKER)) {
1427
- // Step 1: Always commit first (CYCLE_COMPLETE implies end of cycle)
1428
- if (!state.commitPending) {
1415
+ // Step 1: Always commit first in the current session
1416
+ if (!state.commitPending && sessionID) {
1429
1417
  state.commitPending = true;
1430
1418
  console.log("[opencode-immune] Multi-Cycle: CYCLE_COMPLETE detected, running smart commit first...");
1431
1419
  try {
1432
- const ok = await runSmartCommit(state);
1420
+ const ok = await runSmartCommit(state, sessionID);
1433
1421
  if (!ok) {
1434
1422
  console.log("[opencode-immune] Multi-Cycle: smart commit failed, falling back to git commit...");
1435
1423
  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.30",
4
4
  "description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
5
5
  "exports": {
6
6
  "./server": "./dist/plugin.js"