opencode-immune 1.0.82 → 1.0.83

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.
@@ -4123,7 +4123,7 @@ import { fileURLToPath } from "url";
4123
4123
  import { createHash } from "crypto";
4124
4124
  import { tmpdir } from "os";
4125
4125
  import { execFile } from "child_process";
4126
- var PLUGIN_VERSION = "1.0.81";
4126
+ var PLUGIN_VERSION = "1.0.83";
4127
4127
  var PLUGIN_PACKAGE_NAME = "opencode-immune";
4128
4128
  var PLUGIN_DIRNAME = dirname(fileURLToPath(import.meta.url));
4129
4129
  function getServerAuthHeaders() {
@@ -4136,8 +4136,9 @@ function getServerAuthHeaders() {
4136
4136
  async function getPluginVersion() {
4137
4137
  try {
4138
4138
  const candidates = [
4139
- join(PLUGIN_DIRNAME, "..", "package.json"),
4140
- join(PLUGIN_DIRNAME, "package.json")
4139
+ join(PLUGIN_DIRNAME, "..", "..", "package.json"),
4140
+ join(PLUGIN_DIRNAME, "package.json"),
4141
+ join(PLUGIN_DIRNAME, "..", "package.json")
4141
4142
  ];
4142
4143
  for (const pkgPath of candidates) {
4143
4144
  try {
@@ -4151,6 +4152,41 @@ async function getPluginVersion() {
4151
4152
  }
4152
4153
  return PLUGIN_VERSION;
4153
4154
  }
4155
+ async function installLatestPluginUpdate(state, currentVersion, latestVersion) {
4156
+ try {
4157
+ writePluginLog(
4158
+ state,
4159
+ "info",
4160
+ `[opencode-immune] Installing plugin update ${currentVersion} \u2192 ${latestVersion}.`
4161
+ );
4162
+ await execFileAsync("opencode", ["plugin", `${PLUGIN_PACKAGE_NAME}@latest`, "--force"], {
4163
+ cwd: state.input.directory,
4164
+ env: process.env
4165
+ });
4166
+ state.pluginUpdateMessage = `[PLUGIN UPDATE] opencode-immune ${currentVersion} \u2192 ${latestVersion} was installed automatically. Restart opencode to load the new plugin code.`;
4167
+ await writeDiagnosticLog(state, "plugin-update:install", {
4168
+ from: currentVersion,
4169
+ to: latestVersion,
4170
+ status: "installed"
4171
+ });
4172
+ return true;
4173
+ } catch (err) {
4174
+ writePluginLog(
4175
+ state,
4176
+ "warn",
4177
+ `[opencode-immune] Automatic plugin update failed for ${PLUGIN_PACKAGE_NAME}@latest.`,
4178
+ { error: normalizeLogValue(err) }
4179
+ );
4180
+ state.pluginUpdateMessage = `[PLUGIN UPDATE] opencode-immune ${currentVersion} \u2192 ${latestVersion} is available, but automatic install failed. Run \`opencode plugin ${PLUGIN_PACKAGE_NAME}@latest --force\`, then restart opencode. If opencode still loads the old package, clear its package cache with \`rm -rf ~/.cache/opencode/packages/${PLUGIN_PACKAGE_NAME}@latest\` and run the update command again.`;
4181
+ await writeDiagnosticLog(state, "plugin-update:install", {
4182
+ from: currentVersion,
4183
+ to: latestVersion,
4184
+ status: "failed",
4185
+ error: err instanceof Error ? err.message : String(err)
4186
+ });
4187
+ return false;
4188
+ }
4189
+ }
4154
4190
  async function checkPluginUpdate(state) {
4155
4191
  try {
4156
4192
  const currentVersion = await getPluginVersion();
@@ -4165,12 +4201,12 @@ async function checkPluginUpdate(state) {
4165
4201
  const data = await res.json();
4166
4202
  const latest = data.version;
4167
4203
  if (latest && latest !== currentVersion) {
4168
- state.pluginUpdateMessage = `[PLUGIN UPDATE] opencode-immune ${currentVersion} \u2192 ${latest} is available. Please inform the user: run \`opencode plugin opencode-immune@latest --force\`, then restart opencode. If opencode still loads the old package, clear its package cache with \`rm -rf ~/.cache/opencode/packages/opencode-immune@latest\` and run the update command again.`;
4169
4204
  writePluginLog(
4170
4205
  state,
4171
4206
  "warn",
4172
4207
  `[opencode-immune] Plugin update available: ${currentVersion} \u2192 ${latest}.`
4173
4208
  );
4209
+ await installLatestPluginUpdate(state, currentVersion, latest);
4174
4210
  } else if (latest) {
4175
4211
  writePluginLog(
4176
4212
  state,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-immune",
3
- "version": "1.0.82",
3
+ "version": "1.0.83",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
6
6
  "exports": {