opencode-immune 1.0.82 → 1.0.84
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/server.js +40 -5
- package/package.json +2 -1
package/dist/plugin/server.js
CHANGED
|
@@ -4123,7 +4123,6 @@ 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";
|
|
4127
4126
|
var PLUGIN_PACKAGE_NAME = "opencode-immune";
|
|
4128
4127
|
var PLUGIN_DIRNAME = dirname(fileURLToPath(import.meta.url));
|
|
4129
4128
|
function getServerAuthHeaders() {
|
|
@@ -4136,8 +4135,9 @@ function getServerAuthHeaders() {
|
|
|
4136
4135
|
async function getPluginVersion() {
|
|
4137
4136
|
try {
|
|
4138
4137
|
const candidates = [
|
|
4139
|
-
join(PLUGIN_DIRNAME, "..", "package.json"),
|
|
4140
|
-
join(PLUGIN_DIRNAME, "package.json")
|
|
4138
|
+
join(PLUGIN_DIRNAME, "..", "..", "package.json"),
|
|
4139
|
+
join(PLUGIN_DIRNAME, "package.json"),
|
|
4140
|
+
join(PLUGIN_DIRNAME, "..", "package.json")
|
|
4141
4141
|
];
|
|
4142
4142
|
for (const pkgPath of candidates) {
|
|
4143
4143
|
try {
|
|
@@ -4149,7 +4149,42 @@ async function getPluginVersion() {
|
|
|
4149
4149
|
}
|
|
4150
4150
|
} catch {
|
|
4151
4151
|
}
|
|
4152
|
-
return
|
|
4152
|
+
return "0.0.0";
|
|
4153
|
+
}
|
|
4154
|
+
async function installLatestPluginUpdate(state, currentVersion, latestVersion) {
|
|
4155
|
+
try {
|
|
4156
|
+
writePluginLog(
|
|
4157
|
+
state,
|
|
4158
|
+
"info",
|
|
4159
|
+
`[opencode-immune] Installing plugin update ${currentVersion} \u2192 ${latestVersion}.`
|
|
4160
|
+
);
|
|
4161
|
+
await execFileAsync("opencode", ["plugin", `${PLUGIN_PACKAGE_NAME}@latest`, "--force"], {
|
|
4162
|
+
cwd: state.input.directory,
|
|
4163
|
+
env: process.env
|
|
4164
|
+
});
|
|
4165
|
+
state.pluginUpdateMessage = `[PLUGIN UPDATE] opencode-immune ${currentVersion} \u2192 ${latestVersion} was installed automatically. Restart opencode to load the new plugin code.`;
|
|
4166
|
+
await writeDiagnosticLog(state, "plugin-update:install", {
|
|
4167
|
+
from: currentVersion,
|
|
4168
|
+
to: latestVersion,
|
|
4169
|
+
status: "installed"
|
|
4170
|
+
});
|
|
4171
|
+
return true;
|
|
4172
|
+
} catch (err) {
|
|
4173
|
+
writePluginLog(
|
|
4174
|
+
state,
|
|
4175
|
+
"warn",
|
|
4176
|
+
`[opencode-immune] Automatic plugin update failed for ${PLUGIN_PACKAGE_NAME}@latest.`,
|
|
4177
|
+
{ error: normalizeLogValue(err) }
|
|
4178
|
+
);
|
|
4179
|
+
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.`;
|
|
4180
|
+
await writeDiagnosticLog(state, "plugin-update:install", {
|
|
4181
|
+
from: currentVersion,
|
|
4182
|
+
to: latestVersion,
|
|
4183
|
+
status: "failed",
|
|
4184
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4185
|
+
});
|
|
4186
|
+
return false;
|
|
4187
|
+
}
|
|
4153
4188
|
}
|
|
4154
4189
|
async function checkPluginUpdate(state) {
|
|
4155
4190
|
try {
|
|
@@ -4165,12 +4200,12 @@ async function checkPluginUpdate(state) {
|
|
|
4165
4200
|
const data = await res.json();
|
|
4166
4201
|
const latest = data.version;
|
|
4167
4202
|
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
4203
|
writePluginLog(
|
|
4170
4204
|
state,
|
|
4171
4205
|
"warn",
|
|
4172
4206
|
`[opencode-immune] Plugin update available: ${currentVersion} \u2192 ${latest}.`
|
|
4173
4207
|
);
|
|
4208
|
+
await installLatestPluginUpdate(state, currentVersion, latest);
|
|
4174
4209
|
} else if (latest) {
|
|
4175
4210
|
writePluginLog(
|
|
4176
4211
|
state,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-immune",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.84",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
|
|
6
6
|
"exports": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "esbuild plugin.ts --bundle --platform=node --format=esm --target=node22 --outfile=dist/plugin/server.js && esbuild plugin.ts --bundle --platform=node --format=esm --target=node22 --outfile=dist/plugin.js",
|
|
16
16
|
"dev": "node ./node_modules/typescript/bin/tsc --project tsconfig.json --watch",
|
|
17
|
+
"release": "cd .. && bash scripts/release-plugin.sh",
|
|
17
18
|
"prepublishOnly": "npm run build"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|