opencode-immune 1.0.13 → 1.0.15

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 +43 -1
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -497,6 +497,11 @@ function createSessionRecoveryEvent(state) {
497
497
  if (recovery.phase !== "ARCHIVE: DONE") {
498
498
  // Register this root session as managed so retry/recovery works
499
499
  await addManagedUltraworkSession(state, sessionID);
500
+ // Skip sending AUTO-RESUME if already sent from plugin init
501
+ if (state.autoResumeAttempted) {
502
+ console.log(`[opencode-immune] Auto-resume already sent from plugin init, skipping duplicate for session ${sessionID}.`);
503
+ return;
504
+ }
500
505
  setTimeout(async () => {
501
506
  try {
502
507
  await state.input.client.session.promptAsync({
@@ -998,8 +1003,45 @@ async function server(input) {
998
1003
  const recovery = await parseTasksFile(state.input.directory);
999
1004
  if (recovery && recovery.phase !== "ARCHIVE: DONE") {
1000
1005
  state.recoveryContext = recovery;
1006
+ state.autoResumeAttempted = true;
1001
1007
  console.log(`[opencode-immune] Plugin init: ultrawork marker active, recovery context loaded: ` +
1002
- `task="${recovery.task}", level=${recovery.level}, phase=${recovery.phase}`);
1008
+ `task="${recovery.task}", level=${recovery.level}, phase=${recovery.phase}. ` +
1009
+ `Will create new session and send AUTO-RESUME.`);
1010
+ // Create a new session and send AUTO-RESUME prompt (same pattern as CYCLE_COMPLETE).
1011
+ // Delay to let opencode fully initialize.
1012
+ setTimeout(async () => {
1013
+ try {
1014
+ const createResult = await state.input.client.session.create({
1015
+ body: {
1016
+ title: `AUTO-RESUME: ${recovery.task}`,
1017
+ },
1018
+ });
1019
+ const newSessionData = createResult?.data;
1020
+ const newSessionID = newSessionData?.id;
1021
+ if (!newSessionID) {
1022
+ console.error("[opencode-immune] Auto-resume: Failed to create session — no session ID returned.");
1023
+ return;
1024
+ }
1025
+ console.log(`[opencode-immune] Auto-resume: New session created: ${newSessionID}`);
1026
+ await addManagedUltraworkSession(state, newSessionID);
1027
+ await state.input.client.session.promptAsync({
1028
+ body: {
1029
+ agent: ULTRAWORK_AGENT,
1030
+ parts: [
1031
+ {
1032
+ type: "text",
1033
+ text: `[AUTO-RESUME] Previous session was interrupted. Read memory-bank/tasks.md, check the Phase Status block, and continue the pipeline. Use ONLY the Phase Status block to determine the next phase. Do NOT analyze or evaluate the content of tasks.md. Call the appropriate router with the exact neutral prompt from your Step 5 table.`,
1034
+ },
1035
+ ],
1036
+ },
1037
+ path: { id: newSessionID },
1038
+ });
1039
+ console.log(`[opencode-immune] Auto-resume prompt sent to new session ${newSessionID}`);
1040
+ }
1041
+ catch (err) {
1042
+ console.error("[opencode-immune] Auto-resume: Failed to create session or send prompt:", err);
1043
+ }
1044
+ }, 5_000);
1003
1045
  }
1004
1046
  }
1005
1047
  console.log(`[opencode-immune] Plugin initialized. Directory: ${input.directory}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-immune",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
5
5
  "exports": {
6
6
  "./server": "./dist/plugin.js"